build: add proper dependency checking to configure.ac
authorDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 23 Oct 2012 09:35:49 +0000 (11:35 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 23 Oct 2012 09:35:49 +0000 (11:35 +0200)
We build several tools inside of this repository and we need to make sure
all dependencies are met. Furthermore, we must make sure that default
values are recognized even on dependencies.
Hence, this reworks the whole configure.ac handling and does some renaming
of the constants that are used all over the source.

We need to test this some more weeks, but it should finally be a proper
autotools handling that we can release with kmscon-6.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Makefile.am
autogen.sh
configure.ac
src/kmscon_compositor.h
src/libeloop.pc.in [moved from libeloop.pc.in with 100% similarity]
src/libtsm.pc.in [moved from libtsm.pc.in with 100% similarity]
src/libuterm.pc.in [moved from libuterm.pc.in with 100% similarity]
src/text.h
src/uterm_monitor.c
src/uterm_video.h

index 3f8f1a6..8fd191c 100644 (file)
@@ -15,17 +15,6 @@ CLEANFILES =
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA =
 
-#
-# Build targets
-#
-# kmscon: Main kmscon program
-# test_output: Test program for the display graphics subsystem
-# test_vt: Test program for the VT subsystem
-# test_input: Test program for the input subsystem
-# libkmscon-core: Static core library for kmscon and test programs
-# genshader: Program used to convert shaders into C-source files
-#
-
 bin_PROGRAMS =
 check_PROGRAMS =
 noinst_PROGRAMS = \
@@ -39,8 +28,7 @@ lib_LTLIBRARIES =
 # Make all files include "config.h" by default. This shouldn't cause any
 # problems and we cannot forget to include it anymore.
 #
-# Also make the linker discard all unused symbols as we are not building a
-# shared library.
+# Also make the linker discard all unused symbols.
 #
 # When compiling in debug mode, we enable debug symbols so debugging with gdb
 # is easier. If optimizations are disabled, we pass -O0 to the compiler.
@@ -51,8 +39,7 @@ AM_CFLAGS = \
        -Wall
 AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
-       -I $(srcdir)/src \
-       -I $(srcdir)/external
+       -I $(srcdir)/src
 AM_LDFLAGS = \
        -Wl,--as-needed
 
@@ -71,6 +58,9 @@ endif
 # The SHL subsystem contains several small code pieces used all over kmscon and
 # other applications.
 #
+# Simply include $(SHL_*) in your source-file list. Except for SHL_MISC none of
+# these have external dependencies. SHL_MISC needs xkbcommon.
+#
 
 SHL_DLIST = \
        src/shl_dlist.h
@@ -101,7 +91,7 @@ SHL_MISC = \
 if BUILD_ENABLE_ELOOP
 lib_LTLIBRARIES += libeloop.la
 include_HEADERS += src/eloop.h
-pkgconfig_DATA += libeloop.pc
+pkgconfig_DATA += src/libeloop.pc
 endif
 
 libeloop_la_SOURCES = \
@@ -111,20 +101,23 @@ libeloop_la_SOURCES = \
        src/eloop.h \
        src/eloop.c
 
-if BUILD_ENABLE_DBUS
+libeloop_la_CPPFLAGS = \
+       $(AM_CPPFLAGS)
+libeloop_la_LIBADD =
+libeloop_la_LDFLAGS = \
+       -version-info 1:0:0
+
+
+if BUILD_ENABLE_ELOOP_DBUS
 libeloop_la_SOURCES += \
        external/dbus-common.h \
        external/dbus-loop.h \
        external/dbus-loop.c
-endif
-
-libeloop_la_CPPFLAGS = \
-       $(AM_CPPFLAGS) \
+libeloop_la_CPPFLAGS += \
        $(DBUS_CFLAGS)
-libeloop_la_LIBADD = \
+libeloop_la_LIBADD += \
        $(DBUS_LIBS)
-libeloop_la_LDFLAGS = \
-       -version-info 1:0:0
+endif
 
 #
 # libtsm
@@ -134,12 +127,14 @@ libeloop_la_LDFLAGS = \
 #
 
 if BUILD_ENABLE_TSM
-lib_LTLIBRARIES += libtsm.la
+lib_LTLIBRARIES += \
+       libtsm.la
 include_HEADERS += \
        src/tsm_screen.h \
        src/tsm_unicode.h \
        src/tsm_vte.h
-pkgconfig_DATA += libtsm.pc
+pkgconfig_DATA += \
+       src/libtsm.pc
 endif
 
 libtsm_la_SOURCES = \
@@ -173,7 +168,7 @@ libtsm_la_LDFLAGS = \
 if BUILD_ENABLE_UTERM
 lib_LTLIBRARIES += libuterm.la
 include_HEADERS += src/uterm.h
-pkgconfig_DATA += libuterm.pc
+pkgconfig_DATA += src/libuterm.pc
 endif
 
 libuterm_la_SOURCES = \
@@ -188,48 +183,56 @@ libuterm_la_SOURCES = \
        src/uterm_vt.c \
        src/uterm_input.c \
        src/uterm_input_uxkb.c
+
 nodist_libuterm_la_SOURCES =
 
 libuterm_la_CPPFLAGS = \
        $(AM_CPPFLAGS) \
-       $(SYSTEMD_CFLAGS) \
-       $(DRM_CFLAGS) \
-       $(EGL_CFLAGS) \
-       $(GBM_CFLAGS) \
-       $(GLES2_CFLAGS) \
-       $(UDEV_CFLAGS) \
        $(XKBCOMMON_CFLAGS)
-libuterm_la_LIBADD = \
-       $(SYSTEMD_LIBS) \
-       $(DRM_LIBS) \
-       $(EGL_LIBS) \
-       $(GBM_LIBS) \
-       $(GLES2_LIBS) \
-       $(UDEV_LIBS) \
+libuterm_la_LIBADD =
        $(XKBCOMMON_LIBS) \
        libeloop.la
 libuterm_la_LDFLAGS = \
        -version-info 1:0:0
 
-if BUILD_ENABLE_FBDEV
-libuterm_la_SOURCES += \
-       src/uterm_video_fbdev.c
+if BUILD_ENABLE_MULTI_SEAT
+libuterm_la_CPPFLAGS += $(SYSTEMD_CFLAGS)
+libuterm_la_LIBADD += $(SYSTEMD_LIBS)
 endif
 
-if BUILD_ENABLE_DRM
-libuterm_la_SOURCES += \
-       src/uterm_video_drm.c
+if BUILD_ENABLE_HOTPLUG
+libuterm_la_CPPFLAGS += $(UDEV_CFLAGS)
+libuterm_la_LIBADD += $(UDEV_LIBS)
+endif
+
+if BUILD_ENABLE_VIDEO_FBDEV
+libuterm_la_SOURCES += src/uterm_video_fbdev.c
+endif
+
+if BUILD_ENABLE_VIDEO_DUMB
+libuterm_la_SOURCES += src/uterm_video_dumb.c
+libuterm_la_CPPFLAGS += $(DRM_CFLAGS)
+libuterm_la_LIBADD += $(DRM_LIBS)
+endif
+
+if BUILD_ENABLE_VIDEO_DRM
 libuterm_la_SOURCES += \
+       src/uterm_video_drm.c \
        src/static_gl.h \
        src/static_gl_math.c \
        src/static_gl_shader.c
 nodist_libuterm_la_SOURCES += \
        src/static_shaders.c
-endif
-
-if BUILD_ENABLE_DUMB
-libuterm_la_SOURCES += \
-       src/uterm_video_dumb.c
+libuterm_la_CPPFLAGS += \
+       $(DRM_CFLAGS) \
+       $(EGL_CFLAGS) \
+       $(GBM_CFLAGS) \
+       $(GLES2_CFLAGS)
+libuterm_la_LIBADD += \
+       $(DRM_LIBS) \
+       $(EGL_LIBS) \
+       $(GBM_LIBS) \
+       $(GLES2_LIBS)
 endif
 
 #
@@ -251,13 +254,9 @@ SHADERS = \
        $(srcdir)/src/static_gltex.vert \
        $(srcdir)/src/static_gltex.frag
 
-EXTRA_DIST += \
-       $(SHADERS)
-CLEANFILES += \
-       src/static_shaders.c
-
-genshader_SOURCES = \
-       src/genshader.c
+EXTRA_DIST += $(SHADERS)
+CLEANFILES += src/static_shaders.c
+genshader_SOURCES = src/genshader.c
 
 src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
        $(AM_V_GEN)./genshader$(EXEEXT) src/static_shaders.c $(SHADERS)
@@ -267,16 +266,11 @@ src/static_shaders.c: $(SHADERS) genshader$(EXEEXT)
 # This generates the unifont sources from raw hex-encoded font data.
 #
 
-UNIFONT = \
-       src/text_font_unifont_data.hex
+UNIFONT = src/text_font_unifont_data.hex
 
-EXTRA_DIST += \
-       $(UNIFONT)
-CLEANFILES += \
-       src/text_font_unifont_data.c
-
-genunifont_SOURCES = \
-       src/genunifont.c
+EXTRA_DIST += $(UNIFONT)
+CLEANFILES += src/text_font_unifont_data.c
+genunifont_SOURCES = src/genunifont.c
 
 src/text_font_unifont_data.c: $(UNIFONT) genunifont$(EXEEXT)
        $(AM_V_GEN)./genunifont$(EXEEXT) src/text_font_unifont_data.c $(UNIFONT)
@@ -304,97 +298,33 @@ libtext_font_la_SOURCES = \
        src/text_font.c
 nodist_libtext_font_la_SOURCES =
 
-if BUILD_ENABLE_UNIFONT
-libtext_font_la_SOURCES += \
-       src/text_font_unifont.c
-nodist_libtext_font_la_SOURCES += \
-       src/text_font_unifont_data.c
-endif
-
-if BUILD_ENABLE_8X16
-libtext_font_la_SOURCES += \
-       src/text_font_8x16.c
-endif
-
-if BUILD_ENABLE_FREETYPE2
-libtext_font_la_SOURCES += \
-       src/text_font_freetype2.c
-endif
-
-if BUILD_ENABLE_PANGO
-libtext_font_la_SOURCES += \
-       src/text_font_pango.c
-endif
-
 libtext_font_la_CPPFLAGS = \
-       $(AM_CPPFLAGS) \
-       $(PANGO_CFLAGS) \
-       $(FREETYPE2_CFLAGS)
+       $(AM_CPPFLAGS)
 libtext_font_la_LIBADD = \
-       $(PANGO_LIBS) \
-       $(FREETYPE2_LIBS) \
        -lpthread \
        libtsm.la
 
-#
-# libkmscon-core
-# This static library contains all the source files used in kmscon. We build
-# them as separate library to allow linking them to the test programs.
-# Only "main.c" is not included here as it contains the main() function.
-#
-
-if BUILD_ENABLE_KMSCON
-noinst_LTLIBRARIES += libkmscon-core.la
+if BUILD_ENABLE_FONT_8X16
+libtext_font_la_SOURCES += src/text_font_8x16.c
 endif
 
-libkmscon_core_la_SOURCES = \
-       $(SHL_DLIST) \
-       $(SHL_ARRAY) \
-       $(SHL_HASHTABLE) \
-       $(SHL_RING) \
-       $(SHL_TIMER) \
-       $(SHL_HOOK) \
-       $(SHL_MISC) \
-       src/conf.c src/conf.h \
-       src/log.c src/log.h \
-       src/pty.c src/pty.h \
-       src/text.h \
-       src/text.c
-nodist_libkmscon_core_la_SOURCES =
-
-if BUILD_ENABLE_BBLIT
-libkmscon_core_la_SOURCES += \
-       src/text_bblit.c
+if BUILD_ENABLE_FONT_UNIFONT
+libtext_font_la_SOURCES += src/text_font_unifont.c
+nodist_libtext_font_la_SOURCES += src/text_font_unifont_data.c
 endif
 
-if BUILD_ENABLE_BBULK
-libkmscon_core_la_SOURCES += \
-       src/text_bbulk.c
+if BUILD_ENABLE_FONT_FREETYPE2
+libtext_font_la_SOURCES += src/text_font_freetype2.c
+libtext_font_la_CPPFLAGS += $(FREETYPE2_CFLAGS)
+libtext_font_la_LIBADD += $(FREETYPE2_LIBS)
 endif
 
-if BUILD_ENABLE_GLES2
-libkmscon_core_la_SOURCES += \
-       src/text_gltex.c \
-       src/static_gl.h \
-       src/static_gl_math.c \
-       src/static_gl_shader.c
-nodist_libkmscon_core_la_SOURCES += \
-       src/static_shaders.c
+if BUILD_ENABLE_FONT_PANGO
+libtext_font_la_SOURCES += src/text_font_pango.c
+libtext_font_la_CPPFLAGS += $(PANGO_CFLAGS)
+libtext_font_la_LIBADD += $(PANGO_LIBS)
 endif
 
-libkmscon_core_la_CPPFLAGS = \
-       $(AM_CPPFLAGS) \
-       $(GLES2_CFLAGS) \
-       $(XKBCOMMON_CFLAGS)
-libkmscon_core_la_LIBADD = \
-       $(GLES2_LIBS) \
-       $(XKBCOMMON_LIBS) \
-       -lpthread \
-       libeloop.la \
-       libtsm.la \
-       libuterm.la \
-       libtext-font.la
-
 #
 # Binaries
 # These are the sources for the main binaries and test programs. They mostly
@@ -414,43 +344,72 @@ endif
 kmscon_SOURCES = \
        $(SHL_DLIST) \
        $(SHL_MISC) \
+       $(SHL_ARRAY) \
+       $(SHL_HASHTABLE) \
+       $(SHL_RING) \
+       $(SHL_TIMER) \
+       $(SHL_HOOK) \
+       src/conf.h \
+       src/conf.c \
+       src/log.h \
+       src/log.c \
+       src/pty.h \
+       src/pty.c \
+       src/text.h \
+       src/text.c \
        src/kmscon_terminal.h \
-       src/kmscon_terminal.c \
        src/kmscon_dummy.h \
-       src/kmscon_dummy.c \
+       src/kmscon_compositor.h \
        src/kmscon_seat.h \
        src/kmscon_seat.c \
        src/kmscon_conf.h \
        src/kmscon_conf.c \
        src/kmscon_main.c
+nodist_kmscon_SOURCES =
+
 kmscon_CPPFLAGS = \
        $(AM_CPPFLAGS) \
-       $(WAYLAND_CFLAGS) \
        $(XKBCOMMON_CFLAGS)
 kmscon_LDADD = \
-       $(WAYLAND_LIBS) \
        $(XKBCOMMON_LIBS) \
-       libuterm.la \
        libeloop.la \
+       libuterm.la \
        libtext-font.la \
-       libkmscon-core.la
+       -lpthread
 
-if BUILD_ENABLE_WAYLAND
-kmscon_SOURCES += \
-       src/kmscon_compositor.h \
-       src/kmscon_compositor.c
+if BUILD_ENABLE_SESSION_DUMMY
+kmscon_SOURCES += src/kmscon_dummy.c
 endif
 
-test_output_SOURCES = tests/test_output.c tests/test_include.h
-test_output_LDADD = libkmscon-core.la
+if BUILD_ENABLE_SESSION_TERMINAL
+kmscon_SOURCES += src/kmscon_terminal.c
+kmscon_LDADD += libtsm.la
+endif
 
-test_vt_SOURCES = tests/test_vt.c
-test_vt_LDADD = libkmscon-core.la
+if BUILD_ENABLE_SESSION_COMPOSITOR
+kmscon_SOURCES += src/kmscon_compositor.c
+kmscon_CPPFLAGS += $(WAYLAND_CFLAGS)
+kmscon_LDADD += $(WAYLAND_LIBS)
+endif
 
-test_input_SOURCES = tests/test_input.c
-test_input_LDADD = libkmscon-core.la
+if BUILD_ENABLE_RENDERER_BBLIT
+kmscon_SOURCES += src/text_bblit.c
+endif
 
-test_key_SOURCES = tests/test_key.c
+if BUILD_ENABLE_RENDERER_BBULK
+kmscon_SOURCES += src/text_bbulk.c
+endif
+
+if BUILD_ENABLE_RENDERER_GLTEX
+kmscon_SOURCES += \
+       src/text_gltex.c \
+       src/static_gl.h \
+       src/static_gl_math.c \
+       src/static_gl_shader.c
+nodist_kmscon_SOURCES += src/static_shaders.c
+kmscon_CPPFLAGS += $(GLES2_CFLAGS)
+kmscon_LDADD += $(GLES2_LIBS)
+endif
 
 #
 # Wayland Terminal
@@ -484,9 +443,27 @@ wlterm_CPPFLAGS = \
        $(WAYLAND_CFLAGS) \
        $(XKBCOMMON_CFLAGS)
 wlterm_LDADD = \
+       $(WAYLAND_LIBS) \
+       $(XKBCOMMON_LIBS) \
        libeloop.la \
        libtsm.la \
        libtext-font.la \
-       -lpthread \
-       $(WAYLAND_LIBS) \
-       $(XKBCOMMON_LIBS)
+       -lpthread
+
+#
+# Tests
+#
+
+test_output_SOURCES = \
+       tests/test_include.h \
+       tests/test_output.c
+test_output_LDADD = \
+       libuterm.la
+
+test_vt_SOURCES = tests/test_vt.c
+test_vt_LDADD =
+
+test_input_SOURCES = tests/test_input.c
+test_input_LDADD =
+
+test_key_SOURCES = tests/test_key.c
index a96d6ef..0bb5ca8 100755 (executable)
@@ -4,5 +4,5 @@ mkdir -p m4
 autoreconf -i
 
 if test ! "x$NOCONFIGURE" = "x1" ; then
-    exec ./configure --enable-debug "$@"
+    exec ./configure "$@"
 fi
index e2b0098..bc05695 100644 (file)
@@ -43,642 +43,955 @@ LT_INIT
 # ourself.
 #
 
+PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon],
+                  [have_xkbcommon=yes], [have_xkbcommon=no])
+AC_SUBST(XKBCOMMON_CFLAGS)
+AC_SUBST(XKBCOMMON_LIBS)
+
+PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server wayland-cursor],
+                  [have_wayland=yes], [have_wayland=no])
+AC_SUBST(WAYLAND_CFLAGS)
+AC_SUBST(WAYLAND_LIBS)
+
 PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login],
                   [have_systemd=yes], [have_systemd=no])
+AC_SUBST(SYSTEMD_CFLAGS)
+AC_SUBST(SYSTEMD_LIBS)
 
 PKG_CHECK_MODULES([UDEV], [libudev],
                   [have_udev=yes], [have_udev=no])
+AC_SUBST(UDEV_CFLAGS)
+AC_SUBST(UDEV_LIBS)
 
 PKG_CHECK_MODULES([DBUS], [dbus-1],
                   [have_dbus=yes], [have_dbus=no])
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
 
 PKG_CHECK_MODULES([DRM], [libdrm],
                   [have_drm=yes], [have_drm=no])
+AC_SUBST(DRM_CFLAGS)
+AC_SUBST(DRM_LIBS)
 
 PKG_CHECK_MODULES([GBM], [gbm],
                   [have_gbm=yes], [have_gbm=no])
+AC_SUBST(GBM_CFLAGS)
+AC_SUBST(GBM_LIBS)
 
 PKG_CHECK_MODULES([EGL], [egl],
                   [have_egl=yes], [have_egl=no])
+AC_SUBST(EGL_CFLAGS)
+AC_SUBST(EGL_LIBS)
 
 PKG_CHECK_MODULES([GLES2], [glesv2],
                   [have_gles2=yes], [have_gles2=no])
-
-PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon],
-                  [have_xkbcommon=yes], [have_xkbcommon=no])
+AC_SUBST(GLES2_CFLAGS)
+AC_SUBST(GLES2_LIBS)
 
 PKG_CHECK_MODULES([FREETYPE2], [freetype2 fontconfig],
                   [have_freetype2=yes], [have_freetype2=no])
+AC_SUBST(FREETYPE2_CFLAGS)
+AC_SUBST(FREETYPE2_LIBS)
 
 PKG_CHECK_MODULES([PANGO], [pango pangoft2],
                   [have_pango=yes], [have_pango=no])
-
-PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server wayland-cursor],
-                  [have_wayland=yes], [have_wayland=no])
+AC_SUBST(PANGO_CFLAGS)
+AC_SUBST(PANGO_LIBS)
 
 #
-# Parse arguments for applications
-# Parse all command-line arguments that enable or disable build of applications.
-# This allows us to compute which dependencies we need.
+# Parse arguments
+# This parses all arguments that are given via "--enable-XY" or "--with-XY" and
+# saves the results in local variables. This does not check dependencies or
+# similar but does only parse the arguments.
 #
 
-AC_MSG_CHECKING([whether to compile eloop])
+# eloop
+AC_MSG_CHECKING([whether user wants eloop])
 AC_ARG_ENABLE([eloop],
               [AS_HELP_STRING([--enable-eloop],
                               [build eloop library])])
-AC_MSG_RESULT([ok])
+if test "x$enable_eloop" = "x" ; then
+        enable_eloop="no (default)"
+fi
+AC_MSG_RESULT([$enable_eloop])
 
-AC_MSG_CHECKING([whether to compile TSM])
+# TSM
+AC_MSG_CHECKING([whether user wants TSM])
 AC_ARG_ENABLE([tsm],
               [AS_HELP_STRING([--enable-tsm],
                               [build tsm library])])
-AC_MSG_RESULT([ok])
+if test "x$enable_tsm" = "x" ; then
+        enable_tsm="no (default)"
+fi
+AC_MSG_RESULT([$enable_tsm])
 
-AC_MSG_CHECKING([whether to compile uterm])
+# uterm
+AC_MSG_CHECKING([whether user wants uterm])
 AC_ARG_ENABLE([uterm],
               [AS_HELP_STRING([--enable-uterm],
                               [build uterm library])])
-AC_MSG_RESULT([ok])
+if test "x$enable_uterm" = "x" ; then
+        enable_uterm="no (default)"
+fi
+AC_MSG_RESULT([$enable_uterm])
 
-AC_MSG_CHECKING([whether to compile kmscon])
+# kmscon
+AC_MSG_CHECKING([whether user wants kmscon])
 AC_ARG_ENABLE([kmscon],
               [AS_HELP_STRING([--disable-kmscon],
                               [do not build kmscon])])
-AC_MSG_RESULT([ok])
+if test "x$enable_kmscon" = "x" ; then
+        enable_kmscon="yes (default)"
+fi
+AC_MSG_RESULT([$enable_kmscon])
 
-AC_MSG_CHECKING([whether to build wlterm])
+# wlterm
+AC_MSG_CHECKING([whether user wants wlterm])
 AC_ARG_ENABLE([wlterm],
               [AS_HELP_STRING([--enable-wlterm],
                               [build wlterm])])
-AC_MSG_RESULT([ok])
-
-#
-# Parse depedency arguments
-# This parses all command-line arguments to check for which dependencies should
-# be used and how the applications should be built.
-#
-
-AC_MSG_CHECKING([whether to use systemd for multi-seat support])
-AC_ARG_ENABLE([systemd],
-              [AS_HELP_STRING([--enable-systemd],
-                              [enable multi-seat support with systemd])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use udev for device hotplug support])
-AC_ARG_ENABLE([udev],
-              [AS_HELP_STRING([--enable-udev],
-                              [enable device hotplug support with udev])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use dbus for IPC])
-AC_ARG_ENABLE([dbus],
-              [AS_HELP_STRING([--enable-dbus],
-                              [enable dbus IPC])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to enable wayland features])
-AC_ARG_ENABLE([wayland],
-              [AS_HELP_STRING([--enable-wayland],
-                              [enable wayland features])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use uterm fbdev video backend])
-AC_ARG_ENABLE([fbdev],
-              [AS_HELP_STRING([--enable-fbdev],
-                              [enable uterm fbdev video backend])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use uterm drm video backend])
-AC_ARG_ENABLE([drm],
-              [AS_HELP_STRING([--enable-drm],
-                              [enable uterm drm video backend])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to provide OpenGLES2 support])
-AC_ARG_ENABLE([gles2],
-              [AS_HELP_STRING([--enable-gles2],
-                              [provide uterm OpenGLES2 support])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use static unifont backend])
-AC_ARG_ENABLE([unifont],
-              [AS_HELP_STRING([--enable-unifont],
-                              [enable static unifont font backend (GPL)])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use static 8x16 font backend])
-AC_ARG_ENABLE([f8x16],
-              [AS_HELP_STRING([--disable-f8x16],
-                              [disable static 8x16 font backend])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use freetype2 font backend])
-AC_ARG_ENABLE([freetype2],
-              [AS_HELP_STRING([--disable-freetype2],
-                              [disable freetype2 font backend])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use pango font backend])
-AC_ARG_ENABLE([pango],
-              [AS_HELP_STRING([--disable-pango],
-                              [disable pango font backend])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use bblit rendering backend])
-AC_ARG_ENABLE([bblit],
-              [AS_HELP_STRING([--disable-bblit],
-                              [disable bblit rendering backend])])
-AC_MSG_RESULT([ok])
-
-AC_MSG_CHECKING([whether to use bbulk rendering backend])
-AC_ARG_ENABLE([bbulk],
-              [AS_HELP_STRING([--disable-bbulk],
-                              [disable bbulk rendering backend])])
-AC_MSG_RESULT([ok])
-
-#
-# Parse miscellaneous arguments
-# These don't belong into the categories above for several reason so they are
-# handled specially.
-# They configure compiler options and similar.
-#
+if test "x$enable_wlterm" = "x" ; then
+        enable_wlterm="yes (default)"
+fi
+AC_MSG_RESULT([$enable_wlterm])
 
+# debug
 AC_MSG_CHECKING([whether to build with debugging on])
 AC_ARG_ENABLE([debug],
               [AS_HELP_STRING([--enable-debug],
                               [whether to build with debugging on])])
-AC_MSG_RESULT([ok])
+if test "x$enable_debug" = "x" ; then
+        enable_debug="yes (default)"
+fi
+AC_MSG_RESULT([$enable_debug])
 
+# optimizations
 AC_MSG_CHECKING([whether to disable code optimizations])
 AC_ARG_ENABLE([optimizations],
               [AS_HELP_STRING([--disable-optimizations],
                               [whether to disable code optimizations])])
-AC_MSG_RESULT([ok])
+if test "x$enable_optimizations" = "x" ; then
+        enable_optimizations="yes (default)"
+fi
+AC_MSG_RESULT([$enable_optimizations])
+
+# multi-seat
+AC_MSG_CHECKING([whether user wants systemd for multi-seat support])
+AC_ARG_ENABLE([multi-seat],
+              [AS_HELP_STRING([--enable-multi-seat],
+                              [enable multi-seat support with systemd])])
+if test "x$enable_multi_seat" = "x" ; then
+        enable_multi_seat="yes (default)"
+fi
+AC_MSG_RESULT([$enable_multi_seat])
+
+# hotplug
+AC_MSG_CHECKING([whether user wants udev for device hotplug support])
+AC_ARG_ENABLE([hotplug],
+              [AS_HELP_STRING([--enable-hotplug],
+                              [enable device hotplug support with udev])])
+if test "x$enable_hotplug" = "x" ; then
+        enable_hotplug="yes (default)"
+fi
+AC_MSG_RESULT([$enable_hotplug])
+
+# eloop-dbus
+AC_MSG_CHECKING([whether user wants eloop dbus support])
+AC_ARG_ENABLE([eloop-dbus],
+              [AS_HELP_STRING([--enable-eloop-dbus],
+                              [enable eloop dbus support])])
+if test "x$enable_eloop_dbus" = "x" ; then
+        enable_eloop_dbus="no (default)"
+fi
+AC_MSG_RESULT([$enable_eloop_dbus])
+
+# video backends
+AC_MSG_CHECKING([which video backends the user wants])
+AC_ARG_WITH([video],
+            [AS_HELP_STRING([--with-video],
+              [specify list of optional video backends])])
+enable_video_fbdev="no"
+enable_video_dumb="no"
+enable_video_drm="no"
+if test "x$with_video" = "x" ; then
+        enable_video_fbdev="yes (default)"
+        enable_video_dumb="yes (default)"
+        enable_video_drm="yes (default)"
+        with_video="fbdev,dumb,drm (default)"
+else
+        SAVEIFS="$IFS"
+        IFS=","
+        for i in $with_video ; do
+                if test "x$i" = "xfbdev" ; then
+                        enable_video_fbdev="yes"
+                elif test "x$i" = "xdumb" ; then
+                        enable_video_dumb="yes"
+                elif test "x$i" = "xdrm" ; then
+                        enable_video_drm="yes"
+                else
+                        IFS="$SAVEIFS"
+                        AC_ERROR([Invalid video backend $i])
+                fi
+        done
+        IFS="$SAVEIFS"
+fi
+AC_MSG_RESULT([$with_video])
+
+# renderers
+AC_MSG_CHECKING([which render backends the user wants])
+AC_ARG_WITH([renderers],
+            [AS_HELP_STRING([--with-renderers],
+              [specify list of optional render backends])])
+enable_renderer_bblit="no"
+enable_renderer_bbulk="no"
+enable_renderer_gltex="no"
+if test "x$with_renderers" = "x" ; then
+        enable_renderer_bblit="yes (default)"
+        enable_renderer_bbulk="yes (default)"
+        enable_renderer_gltex="yes (default)"
+        with_renderers="bblit,bbulk,gltex (default)"
+else
+        SAVEIFS="$IFS"
+        IFS=","
+        for i in $with_renderers ; do
+                if test "x$i" = "xbblit" ; then
+                        enable_renderer_bblit="yes"
+                elif test "x$i" = "xbbulk" ; then
+                        enable_renderer_bbulk="yes"
+                elif test "x$i" = "xgltex" ; then
+                        enable_renderer_gltex="yes"
+                else
+                        IFS="$SAVEIFS"
+                        AC_ERROR([Unknown renderer $i])
+                fi
+        done
+        IFS="$SAVEIFS"
+fi
+AC_MSG_RESULT([$with_renderers])
+
+# font backends
+AC_MSG_CHECKING([which font backends the user wants])
+AC_ARG_WITH([fonts],
+            [AS_HELP_STRING([--with-fonts],
+              [specify list of optional font backends])])
+enable_font_8x16="no"
+enable_font_unifont="no"
+enable_font_freetype2="no"
+enable_font_pango="no"
+if test "x$with_fonts" = "x" ; then
+        enable_font_8x16="yes (default)"
+        enable_font_unifont="no (default)"
+        enable_font_freetype2="yes (default)"
+        enable_font_pango="yes (default)"
+        with_fonts="8x16,freetype2,pango (default)"
+else
+        SAVEIFS="$IFS"
+        IFS=","
+        for i in $with_fonts ; do
+                if test "x$i" = "x8x16" ; then
+                        enable_font_8x16="yes"
+                elif test "x$i" = "xunifont" ; then
+                        enable_font_unifont="yes"
+                elif test "x$i" = "xfreetype2" ; then
+                        enable_font_freetype2="yes"
+                elif test "x$i" = "xpango" ; then
+                        enable_font_pango="yes"
+                else
+                        IFS="$SAVEIFS"
+                        AC_ERROR([Unknown font backend $i])
+                fi
+        done
+        IFS="$SAVEIFS"
+fi
+AC_MSG_RESULT([$with_fonts])
+
+# kmscon sessions
+AC_MSG_CHECKING([which sessions the user wants])
+AC_ARG_WITH([sessions],
+            [AS_HELP_STRING([--with-sessions],
+              [specify list of optional sessions])])
+enable_session_dummy="no"
+enable_session_terminal="no"
+enable_session_compositor="no"
+if test "x$with_sessions" = "x" ; then
+        enable_session_dummy="yes (default)"
+        enable_session_terminal="yes (default)"
+        enable_session_compositor="no (default)"
+        with_sessions="dummy,terminal (default)"
+else
+        SAVEIFS="$IFS"
+        IFS=","
+        for i in $with_sessions ; do
+                if test "x$i" = "xdummy" ; then
+                        enable_session_dummy="yes"
+                elif test "x$i" = "xterminal" ; then
+                        enable_session_terminal="yes"
+                elif test "x$i" = "xcompositor" ; then
+                        enable_session_compositor="yes"
+                else
+                        IFS="$SAVEIFS"
+                        AC_ERROR([Unknown session type $i])
+                fi
+        done
+        IFS="$SAVEIFS"
+fi
+AC_MSG_RESULT([$with_sessions])
 
 #
-# Debug mode and code optimizations
-# In debug mode we compile with -g and enable several debug-messages and flags.
-# With optimizations (default), we add -O2 to compile-flags.
+# Check what can be built
+# This checks each configuration option and tests whether all dependencies are
+# met. This is done from bottom up to ensure the right order.
 #
 
-debug_enabled=no
-if test x$enable_debug = xyes ; then
-        debug_enabled=yes
+# debug
+debug_avail=no
+if test ! "x$enable_debug" = "xno" ; then
+        debug_avail=yes
 fi
 
-optimizations_enabled=no
-if test ! x$enable_optimizations = xno ; then
-        optimizations_enabled=yes
+# optimizations
+optimizations_avail=no
+if test ! "x$enable_optimizations" = "xno" ; then
+        optimizations_avail=yes
 fi
 
-if test x$debug_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_DEBUG], [1],
-                  [Enable debug mode])
-else
-        AC_DEFINE([NDEBUG], [1], [No Debug])
+# eloop-dbus
+eloop_dbus_avail=no
+if test ! "x$enable_eloop_dbus" = "xno" ; then
+        if test "x$have_dbus" = "xyes" ; then
+                eloop_dbus_avail=yes
+        elif test "x$enable_eloop_dbus" = "xyes" ; then
+                AC_ERROR([DBus libraries not found for eloop-dbus])
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_DEBUG],
-               [test x$debug_enabled = xyes])
-AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
-               [test x$optimizations_enabled = xyes])
+# eloop
+eloop_avail=no
+if test ! "x$enable_eloop" = "xno" ; then
+        eloop_avail=yes
+fi
 
-# check for _Static_assert
-AC_MSG_CHECKING([whether _Static_assert() is supported])
-AC_LANG([C])
-have_static_assert=yes
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Static_assert(1, "What?");]])],
-                  [AC_DEFINE([BUILD_HAVE_STATIC_ASSERT],
-                             [1],
-                             [Define to 1 if _Static_assert() is supported])],
-                  [have_static_assert=no])
-AC_MSG_RESULT([$have_static_assert])
+# TSM
+tsm_avail=no
+if test ! "x$enable_tsm" = "xno" ; then
+        if test "x$have_xkbcommon" = "xyes" ; then
+                tsm_avail=yes
+        elif test "x$enable_tsm" = "xyes" ; then
+                AC_ERROR([xkbcommon libraries not found for TSM])
+        fi
+fi
 
-#
-# Main applications
-# This checks which applications to build so we can optionally disable unused
-# dependencies below.
-#
-# Dependency Calculations
-# The first thing we do is checking which applications to build. Then we
-# forcibly enable all libraries that are needed by these and then we forcibly
-# enable all other source-code dependecies.
-#
-# The "enable_XY" flag is user input that is set to "yes" if they enabled it
-# explicitly, "no" if they disabled it explicitly or "" (empty) if they did
-# not specify it explicitly. In the latter case we enable it if all dependencies
-# are met, otherwise, we disable it. This does not work for applications,
-# though. If an application is not specified explicitly by the user, then we
-# force the default value.
-# An application also forces all _hard_ dependencies to "yes" and so fails if
-# they cannot be met.
-#
+# video fbdev
+video_fbdev_avail=no
+if test ! "x$enable_video_fbdev" = "xno" ; then
+        # TODO: check for kernel headers
+        video_fbdev_avail=yes
+fi
 
-kmscon_enabled=no
-if test ! x$enable_kmscon = xno ; then
-        kmscon_enabled=yes
-        enable_eloop=yes
-        enable_tsm=yes
-        enable_uterm=yes
+# video dumb
+video_dumb_avail=no
+if test ! "x$enable_video_dumb" = "xno" ; then
+        if test "x$have_drm" = "xyes" ; then
+                video_dumb_avail=yes
+        elif test "x$enable_video_dumb" = "xyes" ; then
+                AC_ERROR([DRM libraries not found for dumb video backend])
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_KMSCON],
-               [test x$kmscon_enabled = xyes])
+# video drm
+video_drm_avail=no
+if test ! "x$enable_video_drm" = "xno" ; then
+        if test "x$have_drm" = "xno" ; then
+                video_drm_avail=no
+        elif test "x$have_gbm" = "xno" ; then
+                video_drm_avail=no
+        elif test "x$have_egl" = "xno" ; then
+                video_drm_avail=no
+        elif test "x$have_gles2" = "xno" ; then
+                video_drm_avail=no
+        else
+                video_drm_avail=yes
+        fi
 
-wlterm_enabled=no
-if test x$enable_wlterm = xyes ; then
-        wlterm_enabled=yes
-        enable_eloop=yes
-        enable_tsm=yes
-        enable_wayland=yes
+        if test "x$video_drm_avail" = "xno" ; then
+                if test "x$enable_video_drm" = "xyes" ; then
+                        AC_ERROR([DRM, gbm or EGL libraries not found for DRM video backend])
+                fi
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_WLTERM],
-               [test x$wlterm_enabled = xyes])
+# uterm
+uterm_avail=no
+if test ! "x$enable_uterm" = "xno" ; then
+        uterm_avail=yes
+fi
 
-uterm_enabled=no
-if test x$enable_uterm = xyes ; then
-        uterm_enabled=yes
-        eloop_enabled=yes
+# multi-seat
+multi_seat_avail=no
+if test ! "x$enable_multi_seat" = "xno" ; then
+        if test "x$have_systemd" = "xyes" ; then
+                multi_seat_avail=yes
+        elif test "x$enable_multi_seat" = "xyes" ; then
+                AC_ERROR([systemd libraries not found for multi-seat support])
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_UTERM],
-               [test x$uterm_enabled = xyes])
+# hotplug
+hotplug_avail=no
+if test ! "x$enable_hotplug" = "xno" ; then
+        if test "x$have_udev" = "xyes" ; then
+                hotplug_avail=yes
+        elif test "x$enable_hotplug" = "xyes" ; then
+                AC_ERROR([udev libraries not found for hotplug support])
+        fi
+fi
 
-eloop_enabled=no
-if test x$enable_eloop = xyes ; then
-        eloop_enabled=yes
+# renderer bblit
+renderer_bblit_avail=no
+if test ! "x$enable_renderer_bblit" = "xno" ; then
+        renderer_bblit_avail=yes
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_ELOOP],
-               [test x$eloop_enabled = xyes])
+# renderer bbulk
+renderer_bbulk_avail=no
+if test ! "x$enable_renderer_bbulk" = "xno" ; then
+        renderer_bbulk_avail=yes
+fi
 
-tsm_enabled=no
-if test x$enable_tsm = xyes ; then
-        tsm_enabled=yes
+# renderer gltex
+renderer_gltex_avail=no
+if test ! "x$enable_renderer_gltex" = "xno" ; then
+        if test "x$have_gles2" = "xyes" ; then
+                renderer_gltex_avail=yes
+        elif test "x$enable_renderer_gltex" = "xyes" ; then
+                AC_ERROR([OpenGLESv2 libraries not found for gltex renderer])
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_TSM],
-               [test x$tsm_enabled = xyes])
+# font 8x16
+font_8x16_avail=no
+if test ! "x$enable_font_8x16" = "xno" ; then
+        font_8x16_avail=yes
+fi
 
-#
-# Systemd dependency
-# We can optionally use systemd for multi-seat support. If systemd is not
-# available or the system was not started with systemd, we simply fall back to
-# single-seat mode.
-#
+# font unifont
+font_unifont_avail=no
+if test ! "x$enable_font_unifont" = "xno" ; then
+        font_unifont_avail=yes
+fi
 
-systemd_enabled=no
-if test ! x$enable_systemd = xno ; then
-        if test x$have_systemd = xyes ; then
-                systemd_enabled=yes
-        elif test x$enable_systemd = xyes ; then
-                AC_ERROR([systemd libraries not found for multi-seat support])
+# font freetype2
+font_freetype2_avail=no
+if test ! "x$enable_font_freetype2" = "xno" ; then
+        if test "x$have_freetype2" ; then
+                font_freetype2_avail=yes
+        elif test "x$enable_font_freetype2" = "xyes" ; then
+                AC_ERROR([freetype2 or fontconfig libs not found for freetype2 font backend])
         fi
 fi
 
-if test x$systemd_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_SYSTEMD], [1],
-                  [Use systemd for multi-seat support])
-else
-        SYSTEMD_CFLAGS=""
-        SYSTEMD_LIBS=""
+# font pango
+font_pango_avail=no
+if test ! "x$enable_font_pango" = "xno" ; then
+        if test "x$have_pango" ; then
+                font_pango_avail=yes
+        elif test "x$enable_font_pango" = "xyes" ; then
+                AC_ERROR([pango libraries not found for pango font backend])
+        fi
 fi
 
-#
-# Udev dependency
-# For hotplugging support we need udev to notify us about system events. If udev
-# is not available, we simply fall back to static mode. Periodic scanning is
-# also supported.
-#
+# session dummy
+session_dummy_avail=no
+if test ! "x$enable_session_dummy" = "xno" ; then
+        session_dummy_avail=yes
+fi
 
-udev_enabled=no
-if test ! x$enable_udev = xno ; then
-        if test x$have_udev = xyes ; then
-                udev_enabled=yes
-        elif test x$enable_udev = xyes ; then
-                AC_ERROR([udev libraries not found for device hotplug support])
+# session terminal
+session_terminal_avail=no
+if test ! "x$enable_session_terminal" = "xno" ; then
+        if test "x$tsm_avail" = "xyes" ; then
+                session_terminal_avail=yes
+        elif test "x$enable_session_terminal" = "xyes" ; then
+                AC_ERROR([TSM cannot be built for kmscon terminal session])
         fi
 fi
 
-if test x$udev_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_UDEV], [1],
-                  [Use udev for device hotplug support])
-else
-        UDEV_CFLAGS=""
-        UDEV_LIBS=""
+# session compositor
+session_compositor_avail=no
+if test ! "x$enable_session_compositor" = "xno" ; then
+        if test "x$have_wayland" = "xyes" ; then
+                session_compositor_avail=yes
+        elif test "x$enable_session_compositor" = "xyes" ; then
+                AC_ERROR([wayland libraries not found for kmscon compositor session])
+        fi
+fi
+
+# kmscon
+kmscon_avail=no
+if test ! "x$enable_kmscon" = "xno" ; then
+        if test "x$eloop_avail" = "xno" ; then
+                kmscon_avail=no
+        elif test "x$tsm_avail" = "xno" ; then
+                kmscon_avail=no
+        elif test "x$uterm_avail" = "xno" ; then
+                kmscon_avail=no
+        else
+                kmscon_avail=yes
+        fi
+
+        if test "x$enable_kmscon" = "xyes" ; then
+                if test "x$kmscon_avail" = "xno" ; then
+                        AC_ERROR([eloop, TSM or uterm cannot be built for kmscon])
+                fi
+        fi
+fi
+
+# wlterm
+wlterm_avail=no
+if test ! "x$enable_wlterm" = "xno" ; then
+        if test "x$tsm_avail" = "xno" ; then
+                wlterm_avail=no
+        elif test "x$eloop_avail" = "xno" ; then
+                wlterm_avail=no
+        fi
+
+        if test "x$enable_wlterm" = "xyes" ; then
+                if test "x$wlterm_avail" = "xno" ; then
+                        AC_ERROR([eloop or TSM cannot be built for wlterm])
+                fi
+        fi
+
+        if test "x$have_wayland" = "xyes" ; then
+                wlterm_avail=yes
+        elif test "x$enable_wlterm" = "xyes" ; then
+                AC_ERROR([wayland libraries not found for wlterm])
+        fi
 fi
 
 #
-# DBus dependency
-# For IPC mechanisms we use DBus. Especially multi-seat enabled multi-session
-# capable applications need DBus to manage application and terminal switching.
+# Enable all required modules
+# We now know which modules can be built by checking the *_avail variables set
+# above. We now only have to disable all modules that are disabled by default
+# and the user didn't force-enable them and no other module that is enabled
+# needs them. This is done top-down of course.
 #
 
-dbus_enabled=no
-if test x$enable_dbus = xyes ; then
-        if test x$have_dbus = xyes ; then
-                dbus_enabled=yes
-        elif test x$enable_dbus = xyes; then
-                AC_ERROR([dbus libraries not found])
+# wlterm
+wlterm_enabled=no
+if test "x$wltem_avail" = "xyes" ; then
+        if test "x${enable_wlterm% *}" = "xyes" ; then
+                wlterm_enabled=yes
+                enable_eloop=yes
+                enable_tsm=yes
         fi
 fi
 
-if test x$dbus_enabled = xyes; then
-        AC_DEFINE([BUILD_ENABLE_DBUS], [1],
-                  [Use dbus for IPC])
-else
-        DBUS_CFLAGS=""
-        DBUS_LIBS=""
+# kmscon
+kmscon_enabled=no
+if test "x$kmscon_avail" = "xyes" ; then
+        if test "x${enable_kmscon% *}" = "xyes" ; then
+                kmscon_enabled=yes
+                enable_eloop=yes
+                enable_uterm=yes
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_DBUS], [test x$dbus_enabled = xyes])
+# session compositor
+session_compositor_enabled=no
+if test "x$session_compositor_avail" = "xyes" ; then
+        if test "x${enable_session_compositor% *}" = "xyes" ; then
+                session_compositor_enabled=yes
+        fi
+fi
 
-#
-# Uterm fbdev backend
-# This checks whether the fbdev backend was requested and enables it then. There
-# are no special dependencies for it except the kernel headers.
-# TODO: check for kernel headers here
-#
+# session terminal
+session_terminal_enabled=no
+if test "x$session_terminal_avail" = "xyes" ; then
+        if test "x${enable_session_terminal% *}" = "xyes" ; then
+                session_terminal_enabled=yes
+                enable_tsm=yes
+        fi
+fi
 
-fbdev_enabled=no
-if test ! x$enable_fbdev = xno ; then
-        fbdev_enabled=yes
+# session dummy
+session_dummy_enabled=no
+if test "x$session_dummy_avail" = "xyes" ; then
+        if test "x${enable_session_dummy% *}" = "xyes" ; then
+                session_dummy_enabled=yes
+        fi
 fi
 
-if test x$fbdev_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_FBDEV], [1],
-                  [Use uterm fbdev video backend])
+# font pango
+font_pango_enabled=no
+if test "x$font_pango_avail" = "xyes" ; then
+        if test "x${enable_font_pango% *}" = "xyes" ; then
+                font_pango_enabled=yes
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_FBDEV], [test x$fbdev_enabled = xyes])
+# font freetype2
+font_freetype2_enabled=no
+if test "x$font_freetype2_avail" = "xyes" ; then
+        if test "x${enable_font_freetype2% *}" = "xyes" ; then
+                font_freetype2_enabled=yes
+        fi
+fi
 
-#
-# Uterm drm backend
-# This checks whether libdrm is available and some combination of libgbm, egl
-# and gl or glesv2. If it is not available, then the drm backend is simply not
-# built.
-#
+# font unifont
+font_unifont_enabled=no
+if test "x$font_unifont_avail" = "xyes" ; then
+        if test "x${enable_font_unifont% *}" = "xyes" ; then
+                font_unifont_enabled=yes
+        fi
+fi
 
-dumb_enabled=no
-drm_enabled=no
-gles2_enabled=no
-if test ! x$enable_drm = xno ; then
-        if test x$have_drm = xyes ; then
-                dumb_enabled=yes
+# font 8x16
+font_8x16_enabled=no
+if test "x$font_8x16_avail" = "xyes" ; then
+        if test "x${enable_font_8x16% *}" = "xyes" ; then
+                font_8x16_enabled=yes
         fi
+fi
 
-        if test ! x$enable_gles2 = xno ; then
-                if test x$have_drm = xyes -a x$have_gbm = xyes -a x$have_egl = xyes ; then
-                        if test x$have_gles2 = xyes ; then
-                                drm_enabled=yes
-                                gles2_enabled=yes
-                        fi
-                fi
+# renderer gltex
+renderer_gltex_enabled=no
+if test "x$renderer_gltex_avail" = "xyes" ; then
+        if test "x${enable_renderer_gltex% *}" = "xyes" ; then
+                renderer_gltex_enabled=yes
         fi
+fi
 
-        if test x$enable_drm = xyes -a x$dumb_enabled = xno ; then
-                AC_ERROR([drm library not found for uterm dumb drm backend])
+# renderer bbulk
+renderer_bbulk_enabled=no
+if test "x$renderer_bbulk_avail" = "xyes" ; then
+        if test "x${enable_renderer_bbulk% *}" = "xyes" ; then
+                renderer_bbulk_enabled=yes
         fi
+fi
 
-        if test x$enable_gles2 = xyes -a x$drm_enabled = xno ; then
-                AC_ERROR([drm, gbm, egl, gl or gles2 libraries not found for uterm drm backend])
+# renderer bblit
+renderer_bblit_enabled=no
+if test "x$renderer_bblit_avail" = "xyes" ; then
+        if test "x${enable_renderer_bblit% *}" = "xyes" ; then
+                renderer_bblit_enabled=yes
         fi
 fi
 
-if test x$dumb_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_DUMB], [1],
-                  [Use uterm dumb drm video backend])
+# hotplug
+hotplug_enabled=no
+if test "x$hotplug_avail" = "xyes" ; then
+        if test "x${enable_hotplug% *}" = "xyes" ; then
+                hotplug_enabled=yes
+        fi
+fi
 
-        if test x$drm_enabled = xyes ; then
-                AC_DEFINE([BUILD_ENABLE_DRM], [1],
-                          [Use uterm DRM video backend])
-        else
-                GBM_CFLAGS=""
-                GBM_LIBS=""
-                EGL_CFLAGS=""
-                EGL_LIBS=""
+# multi-seat
+multi_seat_enabled=no
+if test "x$multi_seat_avail" = "xyes" ; then
+        if test "x${enable_multi_seat% *}" = "xyes" ; then
+                multi_seat_enabled=yes
         fi
-else
-        DRM_CFLAGS=""
-        DRM_LIBS=""
-        GBM_CFLAGS=""
-        GBM_LIBS=""
-        EGL_CFLAGS=""
-        EGL_LIBS=""
 fi
 
-if test x$gles2_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_GLES2], [1],
-                  [Use OpenGLESv2 as drawing backend])
-else
-        GLES2_CFLAGS=""
-        GLES2_LIBS=""
+# uterm
+uterm_enabled=no
+if test "x$uterm_avail" = "xyes" ; then
+        if test "x${enable_uterm% *}" = "xyes" ; then
+                uterm_enabled=yes
+        fi
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_DUMB], [test x$dumb_enabled = xyes])
-AM_CONDITIONAL([BUILD_ENABLE_DRM], [test x$drm_enabled = xyes])
-AM_CONDITIONAL([BUILD_ENABLE_GLES2], [test x$gles2_enabled = xyes])
+# video drm
+video_drm_enabled=no
+if test "x$video_drm_avail" = "xyes" ; then
+        if test "x${enable_video_drm% *}" = "xyes" ; then
+                video_drm_enabled=yes
+        fi
+fi
 
-# check for gbm_bo_get_pitch() function, otherwise gbm_bo_get_stride() is used
-if test x$have_gbm = xyes ; then
-        save_CFLAGS="$CFLAGS"
-        save_LIBS="$LIBS"
-        save_LDFLAGS="$LDFLAGS"
-        CFLAGS="$DRM_CFLAGS $GBM_CFLAGS"
-        LIBS="$DRM_LIBS $GBM_LIBS"
-        LDFLAGS=""
-        AC_CHECK_LIB([gbm],
-                     [gbm_bo_get_pitch],
-                     [AC_DEFINE([BUILD_HAVE_GBM_BO_GET_PITCH],
-                                [1],
-                                [Define to 1 if your libgbm provides gbm_bo_get_pitch])])
-        CFLAGS="$save_CFLAGS"
-        LIBS="$save_LIBS"
-        LDFLAGS="$save_LDFLAGS"
+# video dumb
+video_dumb_enabled=no
+if test "x$video_dumb_avail" = "xyes" ; then
+        if test "x${enable_video_dumb% *}" = "xyes" ; then
+                video_dumb_enabled=yes
+        fi
 fi
 
-#
-# xkbcommon keyboard backend
-# This checks for the xkbcommon library for keyboard handling in uterm. We
-# require this library as there is no other way to handle keyboard input
-# properly.
-#
+# video fbdev
+video_fbdev_enabled=no
+if test "x$video_fbdev_avail" = "xyes" ; then
+        if test "x${enable_video_fbdev% *}" = "xyes" ; then
+                video_fbdev_enabled=yes
+        fi
+fi
 
-if test x$have_xkbcommon = xno ; then
-        AC_ERROR([xkbcommon not found for keyboard backend])
+# tsm
+tsm_enabled=no
+if test "x$tsm_avail" = "xyes" ; then
+        if test "x${enable_tsm% *}" = "xyes" ; then
+                tsm_enabled=yes
+        fi
+fi
+
+# eloop
+eloop_enabled=no
+if test "x$eloop_avail" = "xyes" ; then
+        if test "x${enable_eloop% *}" = "xyes" ; then
+                eloop_enabled=yes
+        fi
+fi
+
+# eloop-dbus
+eloop_dbus_enabled=no
+if test "x$eloop_dbus_avail" = "xyes" ; then
+        if test "x${enable_eloop_dbus% *}" = "xyes" ; then
+                eloop_dbus_enabled=yes
+        fi
+fi
+
+# optimizations
+optimizations_enabled=no
+if test "x$optimizations_avail" = "xyes" ; then
+        if test "x${enable_optimizations% *}" = "xyes" ; then
+                optimizations_enabled=yes
+        fi
+fi
+
+# debug
+debug_enabled=no
+if test "x$debug_avail" = "xyes" ; then
+        if test "x${enable_debug% *}" = "xyes" ; then
+                debug_enabled=yes
+        fi
 fi
 
 #
-# Font backends
-# This checks for the unifont, 8x16, freetype2 and pango font backends and
-# enables them if requested and available.
-#
-# Please note that the Unifont-data is GPL'ed and we compile this statically
-# into our application. I do not consider this a "derivative" but a lawyer may
-# disagree. So please make sure you enable this only if you use the GPL as
-# license for kmscon.
+# Module Configuration
+# We have now done all dependency checking and default-value validation and we
+# now know which modules are enabled via the *_enabled variables.
+# Everything below is related to the configuration of each module and setting
+# the correct flags for the build process.
 #
 
-unifont_enabled=no
-if test x$enable_unifont = xyes ; then
-        unifont_enabled=yes
+# debug
+if test "x$debug_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_DEBUG], [1], [Enable debug mode])
+else
+        AC_DEFINE([NDEBUG], [1], [No Debug])
 fi
 
-if test x$unifont_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_UNIFONT], [1],
-                  [Use static unifont backend])
+AM_CONDITIONAL([BUILD_ENABLE_DEBUG],
+               [test "x$debug_enabled" = "xyes"])
+
+# optimizations
+AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
+               [test "x$optimizations_enabled" = "xyes"])
+
+# eloop-dbus
+AM_CONDITIONAL([BUILD_ENABLE_ELOOP_DBUS],
+               [test "x$eloop_dbus_enabled" = "xyes"])
+
+# eloop
+AM_CONDITIONAL([BUILD_ENABLE_ELOOP],
+               [test "x$eloop_enabled" = "xyes"])
+
+# TSM
+AM_CONDITIONAL([BUILD_ENABLE_TSM],
+               [test "x$tsm_enabled" = "xyes"])
+
+# video fbdev
+if test "x$video_fbdev_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_VIDEO_FBDEV], [1],
+                  [Build uterm fbdev video backend])
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_UNIFONT], [test x$unifont_enabled = xyes])
+AM_CONDITIONAL([BUILD_ENABLE_VIDEO_FBDEV],
+               [test "x$video_fbdev_enabled" = "xyes"])
 
-f8x16_enabled=no
-if test ! x$enable_f8x16 = xno ; then
-        f8x16_enabled=yes
+# video dumb
+if test "x$video_dumb_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_VIDEO_DUMB], [1],
+                  [Build uterm dumb drm video backend])
 fi
 
-if test x$f8x16_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_8X16], [1],
-                  [Use static 8x16 font backend])
+AM_CONDITIONAL([BUILD_ENABLE_VIDEO_DUMB],
+               [test "x$video_dumb_enabled" = "xyes"])
+
+# video drm
+if test "x$video_drm_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_VIDEO_DRM], [1],
+                  [Build uterm drm video backend])
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_8X16], [test x$f8x16_enabled = xyes])
+AM_CONDITIONAL([BUILD_ENABLE_VIDEO_DRM],
+               [test "x$video_drm_enabled" = "xyes"])
 
-freetype2_enabled=no
-if test ! x$enable_freetype2 = xno ; then
-        if test x$have_freetype2 = xyes ; then
-                freetype2_enabled=yes
-        elif test x$enable_freetype2 = xyes ; then
-                AC_ERROR([freetype2/fontconfig not found for freetype2 backend])
-        fi
+# uterm
+AM_CONDITIONAL([BUILD_ENABLE_UTERM],
+               [test "x$uterm_enabled" = "xyes"])
+
+# multi-seat
+if test "x$multi_seat_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_MULTI_SEAT], [1],
+                  [Use systemd for multi-seat support])
 fi
 
-if test x$freetype2_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_FREETYPE2], [1],
-                  [Use freetype2 as font backend])
-else
-        FREETYPE2_CFLAGS=""
-        FREETYPE2_LIBS=""
+AM_CONDITIONAL([BUILD_ENABLE_MULTI_SEAT],
+               [test "x$multi_seat_enabled" = "xyes"])
+
+# hotplug
+if test "x$hotplug_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_HOTPLUG], [1],
+                  [Use udev for hotplug support])
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_FREETYPE2], [test x$freetype2_enabled = xyes])
+AM_CONDITIONAL([BUILD_ENABLE_HOTPLUG],
+               [test "x$hotplug_enabled" = "xyes"])
 
-pango_enabled=no
-if test ! x$enable_pango = xno ; then
-        if test x$have_pango = xyes ; then
-                pango_enabled=yes
-        elif test x$enable_pango = xyes ; then
-                AC_ERROR([pango not found for pango font backend])
-        fi
+# renderer bblit
+if test "x$renderer_bblit_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_RENDERER_BBLIT], [1],
+                  [Build bblit rendering backend])
 fi
 
-if test x$pango_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_PANGO], [1],
-                  [Use pango as font backend])
-else
-        PANGO_CFLAGS=""
-        PANGO_LIBS=""
+AM_CONDITIONAL([BUILD_ENABLE_RENDERER_BBLIT],
+               [test "x$renderer_bblit_enabled" = "xyes"])
+
+# renderer bbulk
+if test "x$renderer_bbulk_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_RENDERER_BBULK], [1],
+                  [Build bbulk rendering backend])
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_PANGO], [test x$pango_enabled = xyes])
+AM_CONDITIONAL([BUILD_ENABLE_RENDERER_BBULK],
+               [test "x$renderer_bbulk_enabled" = "xyes"])
 
-#
-# BBlit Rendering backend
-#
+# renderer gltex
+if test "x$renderer_gltex_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_RENDERER_GLTEX], [1],
+                  [Build gltex rendering backend])
+fi
 
-bblit_enabled=no
-if test ! x$enable_bblit = xno ; then
-        bblit_enabled=yes
+AM_CONDITIONAL([BUILD_ENABLE_RENDERER_GLTEX],
+               [test "x$renderer_gltex_enabled" = "xyes"])
+
+# font 8x16
+if test "x$font_8x16_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_FONT_8X16], [1],
+                  [Build static 8x16 font backend])
 fi
 
-if test x$bblit_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_BBLIT], [1],
-                  [Use bblit rendering backend])
+AM_CONDITIONAL([BUILD_ENABLE_FONT_8X16],
+               [test "x$font_8x16_enabled" = "xyes"])
+
+# font unifont
+if test "x$font_unifont_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_FONT_UNIFONT], [1],
+                  [Build static unifont backend])
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_BBLIT], [test x$bblit_enabled = xyes])
+AM_CONDITIONAL([BUILD_ENABLE_FONT_UNIFONT],
+               [test "x$font_unifont_enabled" = "xyes"])
 
-#
-# BBulk Rendering backend
-#
+# font freetype2
+if test "x$font_freetype2_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_FONT_FREETYPE2], [1],
+                  [Build freetype2 font backend])
+fi
 
-bbulk_enabled=no
-if test ! x$enable_bbulk = xno ; then
-        bbulk_enabled=yes
+AM_CONDITIONAL([BUILD_ENABLE_FONT_FREETYPE2],
+               [test "x$font_freetype2_enabled" = "xyes"])
+
+# font pango
+if test "x$font_pango_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_FONT_PANGO], [1],
+                  [Build pango font backend])
 fi
 
-if test x$bbulk_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_BBULK], [1],
-                  [Use bbulk rendering backend])
+AM_CONDITIONAL([BUILD_ENABLE_FONT_PANGO],
+               [test "x$font_pango_enabled" = "xyes"])
+
+# session dummy
+if test "x$session_dummy_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_SESSION_DUMMY], [1],
+                  [Build dummy session])
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_BBULK], [test x$bbulk_enabled = xyes])
+AM_CONDITIONAL([BUILD_ENABLE_SESSION_DUMMY],
+               [test "x$session_dummy_enabled" = "xyes"])
 
-#
-# OpenGL Texture rendering backend
-# This is not really an option but automatically enabled if OpenGLES2 support
-# was selected.
-#
+# session terminal
+if test "x$session_terminal_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_SESSION_TERMINAL], [1],
+                  [Build terminal session])
+fi
 
-gltex_enabled=no
-if test x$gles2_enabled = xyes ; then
-        gltex_enabled=yes
+AM_CONDITIONAL([BUILD_ENABLE_SESSION_TERMINAL],
+               [test "x$session_terminal_enabled" = "xyes"])
+
+# session compositor
+if test "x$session_compositor_enabled" = "xyes" ; then
+        AC_DEFINE([BUILD_ENABLE_SESSION_COMPOSITOR], [1],
+                  [Build compositor session])
 fi
 
+AM_CONDITIONAL([BUILD_ENABLE_SESSION_COMPOSITOR],
+               [test "x$session_compositor_enabled" = "xyes"])
+
+# kmscon
+AM_CONDITIONAL([BUILD_ENABLE_KMSCON],
+               [test "x$kmscon_enabled" = "xyes"])
+
+# wlterm
+AM_CONDITIONAL([BUILD_ENABLE_WLTERM],
+               [test "x$wlterm_enabled" = "xyes"])
+
 #
-# Wayland
-# This checks whether the wayland libraries are needed and available.
+# Miscellaneous Checks
+# All checks below are independent of module checking or depend on the results
+# of it. They do not have any dependencies themself so they are not part of the
+# module infrastructure.
 #
 
-wayland_enabled=no
-if test ! x$enable_wayland = xno ; then
-        if test x$have_wayland = xyes ; then
-                wayland_enabled=yes
-        elif test x$enable_wayland = xyes ; then
-                AC_ERROR([wayland libraries not found])
-        fi
-fi
+# check for _Static_assert
+AC_MSG_CHECKING([whether _Static_assert() is supported])
+AC_LANG([C])
+have_static_assert=yes
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Static_assert(1, "What?");]])],
+                  [AC_DEFINE([BUILD_HAVE_STATIC_ASSERT],
+                             [1],
+                             [Define to 1 if _Static_assert() is supported])],
+                  [have_static_assert=no])
+AC_MSG_RESULT([$have_static_assert])
 
-if test x$wayland_enabled = xyes ; then
-        AC_DEFINE([BUILD_ENABLE_WAYLAND], [1],
-                  [Enable wayland backends])
-else
-        WAYLAND_CFLAGS=""
-        WAYLAND_LIBS=""
+# check for gbm_bo_get_pitch() function, otherwise gbm_bo_get_stride() is used
+if test x$have_gbm = xyes ; then
+        save_CFLAGS="$CFLAGS"
+        save_LIBS="$LIBS"
+        save_LDFLAGS="$LDFLAGS"
+        CFLAGS="$DRM_CFLAGS $GBM_CFLAGS"
+        LIBS="$DRM_LIBS $GBM_LIBS"
+        LDFLAGS=""
+        AC_CHECK_LIB([gbm],
+                     [gbm_bo_get_pitch],
+                     [AC_DEFINE([BUILD_HAVE_GBM_BO_GET_PITCH],
+                                [1],
+                                [Define to 1 if your libgbm provides gbm_bo_get_pitch])])
+        CFLAGS="$save_CFLAGS"
+        LIBS="$save_LIBS"
+        LDFLAGS="$save_LDFLAGS"
 fi
 
-AM_CONDITIONAL([BUILD_ENABLE_WAYLAND], [test x$wayland_enabled = xyes])
-
 #
 # Makefile vars
 # After everything is configured, we correctly substitute the values for the
 # makefiles.
 #
 
-AC_SUBST(SYSTEMD_CFLAGS)
-AC_SUBST(SYSTEMD_LIBS)
-AC_SUBST(DBUS_CFLAGS)
-AC_SUBST(DBUS_LIBS)
-AC_SUBST(DRM_CFLAGS)
-AC_SUBST(DRM_LIBS)
-AC_SUBST(EGL_CFLAGS)
-AC_SUBST(EGL_LIBS)
-AC_SUBST(GBM_CFLAGS)
-AC_SUBST(GBM_LIBS)
-AC_SUBST(GLES2_CFLAGS)
-AC_SUBST(GLES2_LIBS)
-AC_SUBST(UDEV_CFLAGS)
-AC_SUBST(UDEV_LIBS)
-AC_SUBST(XKBCOMMON_CFLAGS)
-AC_SUBST(XKBCOMMON_LIBS)
-AC_SUBST(FREETYPE2_CFLAGS)
-AC_SUBST(FREETYPE2_LIBS)
-AC_SUBST(PANGO_CFLAGS)
-AC_SUBST(PANGO_LIBS)
-AC_SUBST(WAYLAND_CFLAGS)
-AC_SUBST(WAYLAND_LIBS)
-
-AC_CONFIG_FILES([Makefile libeloop.pc libtsm.pc libuterm.pc])
+AC_CONFIG_FILES([Makefile
+                 src/libeloop.pc
+                 src/libtsm.pc
+                 src/libuterm.pc])
 AC_OUTPUT
 
 #
@@ -689,38 +1002,39 @@ AC_OUTPUT
 
 AC_MSG_NOTICE([Build configuration:
 
-  Applications and libraries:
-              kmscon: $kmscon_enabled
-              wlterm: $wlterm_enabled
-               uterm: $uterm_enabled
-               eloop: $eloop_enabled
-                 tsm: $tsm_enabled
-
-  Miscellaneous options:
-               debug: $debug_enabled
-       optimizations: $optimizations_enabled
-
-  Optional dependencies:
-             systemd: $systemd_enabled
-                udev: $udev_enabled
-                dbus: $dbus_enabled
-             wayland: $wayland_enabled
-
-  libuterm video backends:
-               fbdev: $fbdev_enabled
-            dumb drm: $dumb_enabled
-                 drm: $drm_enabled
-           OpenGLES2: $gles2_enabled
-
-  font backends:
-             unifont: $unifont_enabled
-                8x16: $f8x16_enabled
-           freetype2: $freetype2_enabled
-               pango: $pango_enabled
-
-  rendering backends:
-               bblit: $bblit_enabled
-               bbulk: $bbulk_enabled
-               gltex: $gltex_enabled
-
-       Run "make" to start compilation process])
+  Applications and Libraries:
+               kmscon: $kmscon_enabled ($kmscon_avail)
+               wlterm: $wlterm_enabled ($wlterm_avail)
+                uterm: $uterm_enabled ($uterm_avail)
+                  tsm: $tsm_enabled ($tsm_avail)
+                eloop: $eloop_enabled ($eloop_avail)
+
+  Miscellaneous Options:
+                debug: $debug_enabled ($debug_avail)
+        optimizations: $optimizations_enabled ($optimizations_avail)
+           multi-seat: $multi_seat_enabled ($multi_seat_avail)
+              hotplug: $hotplug_enabled ($hotplug_avail)
+           eloop-dbus: $eloop_dbus_enabled ($eloop_dbus_avail)
+
+  Video Backends:
+                fbdev: $video_fbdev_enabled ($video_fbdev_avail)
+             dumb drm: $video_dumb_enabled ($video_dumb_avail)
+                  drm: $video_drm_enabled ($video_drm_avail)
+
+  Font Backends:
+                 8x16: $font_8x16_enabled ($font_8x16_avail)
+              unifont: $font_unifont_enabled ($font_unifont_avail)
+            freetype2: $font_freetype2_enabled ($font_freetype2_avail)
+                pango: $font_pango_enabled ($font_pango_avail)
+
+  Renderers:
+                bblit: $renderer_bblit_enabled ($renderer_bblit_avail)
+                bbulk: $renderer_bbulk_enabled ($renderer_bbulk_avail)
+                gltex: $renderer_gltex_enabled ($renderer_gltex_avail)
+
+  Session Types:
+                dummy: $session_dummy_enabled ($session_dummy_avail)
+             terminal: $session_terminal_enabled ($session_terminal_avail)
+           compositor: $session_compositor_enabled ($session_compositor_avail)
+
+        Run "make" to start compilation process])
index 47de341..312529b 100644 (file)
 #include <stdlib.h>
 #include "kmscon_seat.h"
 
-#if BUILD_ENABLE_WAYLAND
+#if BUILD_ENABLE_SESSION_COMPOSITOR
 
 int kmscon_compositor_register(struct kmscon_session **out,
                               struct kmscon_seat *seat);
 
-#else /* !BUILD_ENABLE_WAYLAND */
+#else /* !BUILD_ENABLE_SESSION_COMPOSITOR */
 
 static inline int kmscon_compositor_register(struct kmscon_session **out,
                                             struct kmscon_seat *seat)
@@ -46,6 +46,6 @@ static inline int kmscon_compositor_register(struct kmscon_session **out,
        return -EOPNOTSUPP;
 }
 
-#endif /* BUILD_ENABLE_WAYLAND */
+#endif /* BUILD_ENABLE_SESSION_COMPOSITOR */
 
 #endif /* KMSCON_COMPOSITOR_H */
similarity index 100%
rename from libeloop.pc.in
rename to src/libeloop.pc.in
similarity index 100%
rename from libtsm.pc.in
rename to src/libtsm.pc.in
similarity index 100%
rename from libuterm.pc.in
rename to src/libuterm.pc.in
index b61ef59..49baa2b 100644 (file)
@@ -175,44 +175,43 @@ int kmscon_text_render_cb(struct tsm_screen *con, void *data);
 
 /* modularized backends */
 
-#ifdef BUILD_ENABLE_UNIFONT
+#ifdef BUILD_ENABLE_FONT_8X16
 
-int kmscon_font_unifont_load(void);
-void kmscon_font_unifont_unload(void);
+int kmscon_font_8x16_load(void);
+void kmscon_font_8x16_unload(void);
 
 #else
 
-static inline int kmscon_font_unifont_load(void)
+static inline int kmscon_font_8x16_load(void)
 {
        return -EOPNOTSUPP;
 }
 
-static inline void kmscon_font_unifont_unload(void)
+static inline void kmscon_font_8x16_unload(void)
 {
 }
 
 #endif
 
+#ifdef BUILD_ENABLE_FONT_UNIFONT
 
-#ifdef BUILD_ENABLE_8X16
-
-int kmscon_font_8x16_load(void);
-void kmscon_font_8x16_unload(void);
+int kmscon_font_unifont_load(void);
+void kmscon_font_unifont_unload(void);
 
 #else
 
-static inline int kmscon_font_8x16_load(void)
+static inline int kmscon_font_unifont_load(void)
 {
        return -EOPNOTSUPP;
 }
 
-static inline void kmscon_font_8x16_unload(void)
+static inline void kmscon_font_unifont_unload(void)
 {
 }
 
 #endif
 
-#ifdef BUILD_ENABLE_FREETYPE2
+#ifdef BUILD_ENABLE_FONT_FREETYPE2
 
 int kmscon_font_freetype2_load(void);
 void kmscon_font_freetype2_unload(void);
@@ -230,7 +229,7 @@ static inline void kmscon_font_freetype2_unload(void)
 
 #endif
 
-#ifdef BUILD_ENABLE_PANGO
+#ifdef BUILD_ENABLE_FONT_PANGO
 
 int kmscon_font_pango_load(void);
 void kmscon_font_pango_unload(void);
@@ -248,7 +247,7 @@ static inline void kmscon_font_pango_unload(void)
 
 #endif
 
-#ifdef BUILD_ENABLE_BBLIT
+#ifdef BUILD_ENABLE_RENDERER_BBLIT
 
 int kmscon_text_bblit_load(void);
 void kmscon_text_bblit_unload(void);
@@ -266,7 +265,7 @@ static inline void kmscon_text_bblit_unload(void)
 
 #endif
 
-#ifdef BUILD_ENABLE_BBULK
+#ifdef BUILD_ENABLE_RENDERER_BBULK
 
 int kmscon_text_bbulk_load(void);
 void kmscon_text_bbulk_unload(void);
@@ -284,7 +283,7 @@ static inline void kmscon_text_bbulk_unload(void)
 
 #endif
 
-#ifdef BUILD_ENABLE_GLES2
+#ifdef BUILD_ENABLE_RENDERER_GLTEX
 
 int kmscon_text_gltex_load(void);
 void kmscon_text_gltex_unload(void);
@@ -304,8 +303,8 @@ static inline void kmscon_text_gltex_unload(void)
 
 static inline void kmscon_font_load_all(void)
 {
-       kmscon_font_unifont_load();
        kmscon_font_8x16_load();
+       kmscon_font_unifont_load();
        kmscon_font_pango_load();
        kmscon_font_freetype2_load();
 }
@@ -314,8 +313,8 @@ static inline void kmscon_font_unload_all(void)
 {
        kmscon_font_freetype2_unload();
        kmscon_font_pango_unload();
-       kmscon_font_8x16_unload();
        kmscon_font_unifont_unload();
+       kmscon_font_8x16_unload();
 }
 
 static inline void kmscon_text_load_all(void)
index 0ff620e..2ba0565 100644 (file)
@@ -44,7 +44,7 @@
 #include "shl_dlist.h"
 #include "uterm.h"
 
-#ifdef BUILD_ENABLE_SYSTEMD
+#ifdef BUILD_ENABLE_MULTI_SEAT
        #include <systemd/sd-login.h>
 #endif
 
@@ -72,7 +72,7 @@ struct uterm_monitor {
        uterm_monitor_cb cb;
        void *data;
 
-#ifdef BUILD_ENABLE_SYSTEMD
+#ifdef BUILD_ENABLE_MULTI_SEAT
        sd_login_monitor *sd_mon;
        struct ev_fd *sd_mon_fd;
 #endif
@@ -87,7 +87,7 @@ struct uterm_monitor {
 static void monitor_new_seat(struct uterm_monitor *mon, const char *name);
 static void monitor_free_seat(struct uterm_monitor_seat *seat);
 
-#ifdef BUILD_ENABLE_SYSTEMD
+#ifdef BUILD_ENABLE_MULTI_SEAT
 
 static void monitor_refresh_seats(struct uterm_monitor *mon)
 {
@@ -184,7 +184,7 @@ static void monitor_sd_deinit(struct uterm_monitor *mon)
        sd_login_monitor_unref(mon->sd_mon);
 }
 
-#else /* !BUILD_ENABLE_SYSTEMD */
+#else /* !BUILD_ENABLE_MULTI_SEAT */
 
 static void monitor_refresh_seats(struct uterm_monitor *mon)
 {
@@ -205,7 +205,7 @@ static void monitor_sd_deinit(struct uterm_monitor *mon)
 {
 }
 
-#endif /* BUILD_ENABLE_SYSTEMD */
+#endif /* BUILD_ENABLE_MULTI_SEAT */
 
 static void seat_new_dev(struct uterm_monitor_seat *seat,
                                unsigned int type,
@@ -474,7 +474,7 @@ static void monitor_udev_add(struct uterm_monitor *mon,
        }
 
        if (!strcmp(subs, "drm")) {
-#ifdef BUILD_ENABLE_SYSTEMD
+#ifdef BUILD_ENABLE_MULTI_SEAT
                if (udev_device_has_tag(dev, "seat") != 1) {
                        log_debug("adding non-seat'ed device %s", name);
                        return;
@@ -488,7 +488,7 @@ static void monitor_udev_add(struct uterm_monitor *mon,
                sname = udev_device_get_property_value(dev, "ID_SEAT");
                type = UTERM_MONITOR_DRM;
        } else if (!strcmp(subs, "graphics")) {
-#ifdef BUILD_ENABLE_SYSTEMD
+#ifdef BUILD_ENABLE_MULTI_SEAT
                if (udev_device_has_tag(dev, "seat") != 1) {
                        log_debug("adding non-seat'ed device %s", name);
                        return;
@@ -516,7 +516,7 @@ static void monitor_udev_add(struct uterm_monitor *mon,
                        log_debug("adding device without parent %s", name);
                        return;
                }
-#ifdef BUILD_ENABLE_SYSTEMD
+#ifdef BUILD_ENABLE_MULTI_SEAT
                if (udev_device_has_tag(p, "seat") != 1) {
                        log_debug("adding non-seat'ed device %s", name);
                        return;
index 6815cae..1fa8c16 100644 (file)
@@ -86,7 +86,7 @@ struct video_ops {
 
 /* drm */
 
-#ifdef BUILD_ENABLE_DRM
+#ifdef BUILD_ENABLE_VIDEO_DRM
 
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
@@ -148,7 +148,7 @@ extern const struct mode_ops drm_mode_ops;
 extern const struct display_ops drm_display_ops;
 extern const struct video_ops drm_video_ops;
 
-#else /* !BUILD_ENABLE_DRM */
+#else /* !BUILD_ENABLE_VIDEO_DRM */
 
 struct drm_mode {
        int unused;
@@ -167,11 +167,11 @@ static const struct mode_ops drm_mode_ops;
 static const struct display_ops drm_display_ops;
 static const struct video_ops drm_video_ops;
 
-#endif /* BUILD_ENABLE_DRM */
+#endif /* BUILD_ENABLE_VIDEO_DRM */
 
 /* dumb drm */
 
-#ifdef BUILD_ENABLE_DUMB
+#ifdef BUILD_ENABLE_VIDEO_DUMB
 
 #include <xf86drm.h>
 #include <xf86drmMode.h>
@@ -208,7 +208,7 @@ extern const struct mode_ops dumb_mode_ops;
 extern const struct display_ops dumb_display_ops;
 extern const struct video_ops dumb_video_ops;
 
-#else /* !BUILD_ENABLE_DUMB */
+#else /* !BUILD_ENABLE_VIDEO_DUMB */
 
 struct dumb_mode {
        int unused;
@@ -227,11 +227,11 @@ static const struct mode_ops dumb_mode_ops;
 static const struct display_ops dumb_display_ops;
 static const struct video_ops dumb_video_ops;
 
-#endif /* BUILD_ENABLE_DUMB */
+#endif /* BUILD_ENABLE_VIDEO_DUMB */
 
 /* fbdev */
 
-#ifdef BUILD_ENABLE_FBDEV
+#ifdef BUILD_ENABLE_VIDEO_FBDEV
 
 #include <linux/fb.h>
 
@@ -278,7 +278,7 @@ extern const struct mode_ops fbdev_mode_ops;
 extern const struct display_ops fbdev_display_ops;
 extern const struct video_ops fbdev_video_ops;
 
-#else /* !BUILD_ENABLE_FBDEV */
+#else /* !BUILD_ENABLE_VIDEO_FBDEV */
 
 struct fbdev_mode {
        int unused;
@@ -297,7 +297,7 @@ static const struct mode_ops fbdev_mode_ops;
 static const struct display_ops fbdev_display_ops;
 static const struct video_ops fbdev_video_ops;
 
-#endif /* BUILD_ENABLE_FBDEV */
+#endif /* BUILD_ENABLE_VIDEO_FBDEV */
 
 /* uterm_screen */