2 # Kmscon - build configuration script
3 # Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
9 AC_SUBST(PACKAGE_URL, [https://github.com/dvdhrm/kmscon])
10 AC_CONFIG_SRCDIR([src/kmscon_main.c])
11 AC_CONFIG_AUX_DIR([build-aux])
12 AC_CONFIG_MACRO_DIR([m4])
13 AC_CONFIG_HEADER(config.h)
15 AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects dist-bzip2 no-dist-gzip tar-pax -Wall -Werror])
16 AM_SILENT_RULES([yes])
19 # Don't add a default "-g -O2" if CFLAGS wasn't specified. For debugging it is
20 # often more convenient to have "-g -O0". You can still override it by
21 # explicitely setting it on the command line.
26 AC_USE_SYSTEM_EXTENSIONS
30 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
36 # pkg-config dependencies
37 # This unconditionally checks for all dependencies even if they are disabled. We
38 # later look whether all required depedencies are met and finish the
39 # configuration. We group similar packages into one logical group here to avoid
40 # having variables for each single library.
41 # This, however, makes ./configure output very unintuitive error messages if a
42 # package is not found so we must make sure we print more verbose messages
46 PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login],
47 [have_systemd=yes], [have_systemd=no])
49 PKG_CHECK_MODULES([UDEV], [libudev],
50 [have_udev=yes], [have_udev=no])
52 PKG_CHECK_MODULES([DBUS], [dbus-1],
53 [have_dbus=yes], [have_dbus=no])
55 PKG_CHECK_MODULES([DRM], [libdrm],
56 [have_drm=yes], [have_drm=no])
58 PKG_CHECK_MODULES([GBM], [gbm],
59 [have_gbm=yes], [have_gbm=no])
61 PKG_CHECK_MODULES([EGL], [egl],
62 [have_egl=yes], [have_egl=no])
64 PKG_CHECK_MODULES([GLES2], [glesv2],
65 [have_gles2=yes], [have_gles2=no])
67 PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon],
68 [have_xkbcommon=yes], [have_xkbcommon=no])
70 PKG_CHECK_MODULES([FREETYPE2], [freetype2 fontconfig],
71 [have_freetype2=yes], [have_freetype2=no])
73 PKG_CHECK_MODULES([PANGO], [pango pangoft2],
74 [have_pango=yes], [have_pango=no])
76 PKG_CHECK_MODULES([WAYLAND], [wayland-client wayland-server wayland-cursor],
77 [have_wayland=yes], [have_wayland=no])
80 # Parse arguments for applications
81 # Parse all command-line arguments that enable or disable build of applications.
82 # This allows us to compute which dependencies we need.
85 AC_MSG_CHECKING([whether to compile eloop])
86 AC_ARG_ENABLE([eloop],
87 [AS_HELP_STRING([--enable-eloop],
88 [build eloop library])])
91 AC_MSG_CHECKING([whether to compile TSM])
93 [AS_HELP_STRING([--enable-tsm],
94 [build tsm library])])
97 AC_MSG_CHECKING([whether to compile uterm])
98 AC_ARG_ENABLE([uterm],
99 [AS_HELP_STRING([--enable-uterm],
100 [build uterm library])])
103 AC_MSG_CHECKING([whether to compile kmscon])
104 AC_ARG_ENABLE([kmscon],
105 [AS_HELP_STRING([--disable-kmscon],
106 [do not build kmscon])])
109 AC_MSG_CHECKING([whether to build wlterm])
110 AC_ARG_ENABLE([wlterm],
111 [AS_HELP_STRING([--enable-wlterm],
116 # Parse depedency arguments
117 # This parses all command-line arguments to check for which dependencies should
118 # be used and how the applications should be built.
121 AC_MSG_CHECKING([whether to use systemd for multi-seat support])
122 AC_ARG_ENABLE([systemd],
123 [AS_HELP_STRING([--enable-systemd],
124 [enable multi-seat support with systemd])])
127 AC_MSG_CHECKING([whether to use udev for device hotplug support])
128 AC_ARG_ENABLE([udev],
129 [AS_HELP_STRING([--enable-udev],
130 [enable device hotplug support with udev])])
133 AC_MSG_CHECKING([whether to use dbus for IPC])
134 AC_ARG_ENABLE([dbus],
135 [AS_HELP_STRING([--enable-dbus],
139 AC_MSG_CHECKING([whether to use uterm fbdev video backend])
140 AC_ARG_ENABLE([fbdev],
141 [AS_HELP_STRING([--enable-fbdev],
142 [enable uterm fbdev video backend])])
145 AC_MSG_CHECKING([whether to use uterm drm video backend])
147 [AS_HELP_STRING([--enable-drm],
148 [enable uterm drm video backend])])
151 AC_MSG_CHECKING([whether to provide OpenGLES2 support])
152 AC_ARG_ENABLE([gles2],
153 [AS_HELP_STRING([--enable-gles2],
154 [provide uterm OpenGLES2 support])])
157 AC_MSG_CHECKING([whether to use static unifont backend])
158 AC_ARG_ENABLE([unifont],
159 [AS_HELP_STRING([--enable-unifont],
160 [enable static unifont font backend (GPL)])])
163 AC_MSG_CHECKING([whether to use static 8x16 font backend])
164 AC_ARG_ENABLE([f8x16],
165 [AS_HELP_STRING([--disable-f8x16],
166 [disable static 8x16 font backend])])
169 AC_MSG_CHECKING([whether to use freetype2 font backend])
170 AC_ARG_ENABLE([freetype2],
171 [AS_HELP_STRING([--disable-freetype2],
172 [disable freetype2 font backend])])
175 AC_MSG_CHECKING([whether to use pango font backend])
176 AC_ARG_ENABLE([pango],
177 [AS_HELP_STRING([--disable-pango],
178 [disable pango font backend])])
181 AC_MSG_CHECKING([whether to use bblit rendering backend])
182 AC_ARG_ENABLE([bblit],
183 [AS_HELP_STRING([--disable-bblit],
184 [disable bblit rendering backend])])
187 AC_MSG_CHECKING([whether to use bbulk rendering backend])
188 AC_ARG_ENABLE([bbulk],
189 [AS_HELP_STRING([--disable-bbulk],
190 [disable bbulk rendering backend])])
194 # Parse miscellaneous arguments
195 # These don't belong into the categories above for several reason so they are
197 # They configure compiler options and similar.
200 AC_MSG_CHECKING([whether to build with debugging on])
201 AC_ARG_ENABLE([debug],
202 [AS_HELP_STRING([--enable-debug],
203 [whether to build with debugging on])])
206 AC_MSG_CHECKING([whether to disable code optimizations])
207 AC_ARG_ENABLE([optimizations],
208 [AS_HELP_STRING([--disable-optimizations],
209 [whether to disable code optimizations])])
213 # Debug mode and code optimizations
214 # In debug mode we compile with -g and enable several debug-messages and flags.
215 # With optimizations (default), we add -O2 to compile-flags.
219 if test x$enable_debug = xyes ; then
223 optimizations_enabled=no
224 if test ! x$enable_optimizations = xno ; then
225 optimizations_enabled=yes
228 if test x$debug_enabled = xyes ; then
229 AC_DEFINE([BUILD_ENABLE_DEBUG], [1],
232 AC_DEFINE([NDEBUG], [1], [No Debug])
235 AM_CONDITIONAL([BUILD_ENABLE_DEBUG],
236 [test x$debug_enabled = xyes])
237 AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
238 [test x$optimizations_enabled = xyes])
240 # check for _Static_assert
241 AC_MSG_CHECKING([whether _Static_assert() is supported])
243 have_static_assert=yes
244 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Static_assert(1, "What?");]])],
245 [AC_DEFINE([BUILD_HAVE_STATIC_ASSERT],
247 [Define to 1 if _Static_assert() is supported])],
248 [have_static_assert=no])
249 AC_MSG_RESULT([$have_static_assert])
253 # This checks which applications to build so we can optionally disable unused
254 # dependencies below.
256 # Dependency Calculations
257 # The first thing we do is checking which applications to build. Then we
258 # forcibly enable all libraries that are needed by these and then we forcibly
259 # enable all other source-code dependecies.
261 # The "enable_XY" flag is user input that is set to "yes" if they enabled it
262 # explicitly, "no" if they disabled it explicitly or "" (empty) if they did
263 # not specify it explicitly. In the latter case we enable it if all dependencies
264 # are met, otherwise, we disable it. This does not work for applications,
265 # though. If an application is not specified explicitly by the user, then we
266 # force the default value.
267 # An application also forces all _hard_ dependencies to "yes" and so fails if
268 # they cannot be met.
272 if test ! x$enable_kmscon = xno ; then
279 AM_CONDITIONAL([BUILD_ENABLE_KMSCON],
280 [test x$kmscon_enabled = xyes])
283 if test x$enable_wlterm = xyes ; then
290 AM_CONDITIONAL([BUILD_ENABLE_WLTERM],
291 [test x$wlterm_enabled = xyes])
294 if test x$enable_uterm = xyes ; then
299 AM_CONDITIONAL([BUILD_ENABLE_UTERM],
300 [test x$uterm_enabled = xyes])
303 if test x$enable_eloop = xyes ; then
307 AM_CONDITIONAL([BUILD_ENABLE_ELOOP],
308 [test x$eloop_enabled = xyes])
311 if test x$enable_tsm = xyes ; then
315 AM_CONDITIONAL([BUILD_ENABLE_TSM],
316 [test x$tsm_enabled = xyes])
320 # We can optionally use systemd for multi-seat support. If systemd is not
321 # available or the system was not started with systemd, we simply fall back to
326 if test ! x$enable_systemd = xno ; then
327 if test x$have_systemd = xyes ; then
329 elif test x$enable_systemd = xyes ; then
330 AC_ERROR([systemd libraries not found for multi-seat support])
334 if test x$systemd_enabled = xyes ; then
335 AC_DEFINE([BUILD_ENABLE_SYSTEMD], [1],
336 [Use systemd for multi-seat support])
344 # For hotplugging support we need udev to notify us about system events. If udev
345 # is not available, we simply fall back to static mode. Periodic scanning is
350 if test ! x$enable_udev = xno ; then
351 if test x$have_udev = xyes ; then
353 elif test x$enable_udev = xyes ; then
354 AC_ERROR([udev libraries not found for device hotplug support])
358 if test x$udev_enabled = xyes ; then
359 AC_DEFINE([BUILD_ENABLE_UDEV], [1],
360 [Use udev for device hotplug support])
368 # For IPC mechanisms we use DBus. Especially multi-seat enabled multi-session
369 # capable applications need DBus to manage application and terminal switching.
373 if test x$enable_dbus = xyes ; then
374 if test x$have_dbus = xyes ; then
376 elif test x$enable_dbus = xyes; then
377 AC_ERROR([dbus libraries not found])
381 if test x$dbus_enabled = xyes; then
382 AC_DEFINE([BUILD_ENABLE_DBUS], [1],
389 AM_CONDITIONAL([BUILD_ENABLE_DBUS], [test x$dbus_enabled = xyes])
392 # Uterm fbdev backend
393 # This checks whether the fbdev backend was requested and enables it then. There
394 # are no special dependencies for it except the kernel headers.
395 # TODO: check for kernel headers here
399 if test ! x$enable_fbdev = xno ; then
403 if test x$fbdev_enabled = xyes ; then
404 AC_DEFINE([BUILD_ENABLE_FBDEV], [1],
405 [Use uterm fbdev video backend])
408 AM_CONDITIONAL([BUILD_ENABLE_FBDEV], [test x$fbdev_enabled = xyes])
412 # This checks whether libdrm is available and some combination of libgbm, egl
413 # and gl or glesv2. If it is not available, then the drm backend is simply not
420 if test ! x$enable_drm = xno ; then
421 if test x$have_drm = xyes ; then
425 if test ! x$enable_gles2 = xno ; then
426 if test x$have_drm = xyes -a x$have_gbm = xyes -a x$have_egl = xyes ; then
427 if test x$have_gles2 = xyes ; then
434 if test x$enable_drm = xyes -a x$dumb_enabled = xno ; then
435 AC_ERROR([drm library not found for uterm dumb drm backend])
438 if test x$enable_gles2 = xyes -a x$drm_enabled = xno ; then
439 AC_ERROR([drm, gbm, egl, gl or gles2 libraries not found for uterm drm backend])
443 if test x$dumb_enabled = xyes ; then
444 AC_DEFINE([BUILD_ENABLE_DUMB], [1],
445 [Use uterm dumb drm video backend])
447 if test x$drm_enabled = xyes ; then
448 AC_DEFINE([BUILD_ENABLE_DRM], [1],
449 [Use uterm DRM video backend])
465 if test x$gles2_enabled = xyes ; then
466 AC_DEFINE([BUILD_ENABLE_GLES2], [1],
467 [Use OpenGLESv2 as drawing backend])
473 AM_CONDITIONAL([BUILD_ENABLE_DUMB], [test x$dumb_enabled = xyes])
474 AM_CONDITIONAL([BUILD_ENABLE_DRM], [test x$drm_enabled = xyes])
475 AM_CONDITIONAL([BUILD_ENABLE_GLES2], [test x$gles2_enabled = xyes])
477 # check for gbm_bo_get_pitch() function, otherwise gbm_bo_get_stride() is used
478 if test x$have_gbm = xyes ; then
479 save_CFLAGS="$CFLAGS"
481 save_LDFLAGS="$LDFLAGS"
482 CFLAGS="$DRM_CFLAGS $GBM_CFLAGS"
483 LIBS="$DRM_LIBS $GBM_LIBS"
487 [AC_DEFINE([BUILD_HAVE_GBM_BO_GET_PITCH],
489 [Define to 1 if your libgbm provides gbm_bo_get_pitch])])
490 CFLAGS="$save_CFLAGS"
492 LDFLAGS="$save_LDFLAGS"
496 # xkbcommon keyboard backend
497 # This checks for the xkbcommon library for keyboard handling in uterm. We
498 # require this library as there is no other way to handle keyboard input
503 if test ! x$have_xkbcommon = xno ; then
504 xkbcommon_enabled=yes
506 AC_ERROR([xkbcommon not found for keyboard backend])
511 # This checks for the unifont, 8x16, freetype2 and pango font backends and
512 # enables them if requested and available.
514 # Please note that the Unifont-data is GPL'ed and we compile this statically
515 # into our application. I do not consider this a "derivative" but a lawyer may
516 # disagree. So please make sure you enable this only if you use the GPL as
517 # license for kmscon.
521 if test x$enable_unifont = xyes ; then
525 if test x$unifont_enabled = xyes ; then
526 AC_DEFINE([BUILD_ENABLE_UNIFONT], [1],
527 [Use static unifont backend])
530 AM_CONDITIONAL([BUILD_ENABLE_UNIFONT], [test x$unifont_enabled = xyes])
533 if test ! x$enable_f8x16 = xno ; then
537 if test x$f8x16_enabled = xyes ; then
538 AC_DEFINE([BUILD_ENABLE_8X16], [1],
539 [Use static 8x16 font backend])
542 AM_CONDITIONAL([BUILD_ENABLE_8X16], [test x$f8x16_enabled = xyes])
545 if test ! x$enable_freetype2 = xno ; then
546 if test x$have_freetype2 = xyes ; then
547 freetype2_enabled=yes
548 elif test x$enable_freetype2 = xyes ; then
549 AC_ERROR([freetype2/fontconfig not found for freetype2 backend])
553 if test x$freetype2_enabled = xyes ; then
554 AC_DEFINE([BUILD_ENABLE_FREETYPE2], [1],
555 [Use freetype2 as font backend])
561 AM_CONDITIONAL([BUILD_ENABLE_FREETYPE2], [test x$freetype2_enabled = xyes])
564 if test ! x$enable_pango = xno ; then
565 if test x$have_pango = xyes ; then
567 elif test x$enable_pango = xyes ; then
568 AC_ERROR([pango not found for pango font backend])
572 if test x$pango_enabled = xyes ; then
573 AC_DEFINE([BUILD_ENABLE_PANGO], [1],
574 [Use pango as font backend])
580 AM_CONDITIONAL([BUILD_ENABLE_PANGO], [test x$pango_enabled = xyes])
583 # BBlit Rendering backend
587 if test ! x$enable_bblit = xno ; then
591 if test x$bblit_enabled = xyes ; then
592 AC_DEFINE([BUILD_ENABLE_BBLIT], [1],
593 [Use bblit rendering backend])
596 AM_CONDITIONAL([BUILD_ENABLE_BBLIT], [test x$bblit_enabled = xyes])
599 # BBulk Rendering backend
603 if test ! x$enable_bbulk = xno ; then
607 if test x$bbulk_enabled = xyes ; then
608 AC_DEFINE([BUILD_ENABLE_BBULK], [1],
609 [Use bbulk rendering backend])
612 AM_CONDITIONAL([BUILD_ENABLE_BBULK], [test x$bbulk_enabled = xyes])
615 # OpenGL Texture rendering backend
616 # This is not really an option but automatically enabled if OpenGLES2 support
621 if test x$gles2_enabled = xyes ; then
627 # This checks whether the wayland libraries are needed and available.
631 if test ! x$enable_wayland = xno ; then
632 if test x$have_wayland = xyes ; then
634 elif test x$enable_wayland = xyes ; then
635 AC_ERROR([wayland libraries not found])
639 if test x$wayland_enabled = xyes ; then
640 AC_DEFINE([BUILD_ENABLE_WAYLAND], [1],
641 [Enable wayland backends])
649 # After everything is configured, we correctly substitute the values for the
653 AC_SUBST(SYSTEMD_CFLAGS)
654 AC_SUBST(SYSTEMD_LIBS)
655 AC_SUBST(DBUS_CFLAGS)
663 AC_SUBST(GLES2_CFLAGS)
665 AC_SUBST(UDEV_CFLAGS)
667 AC_SUBST(XKBCOMMON_CFLAGS)
668 AC_SUBST(XKBCOMMON_LIBS)
669 AC_SUBST(FREETYPE2_CFLAGS)
670 AC_SUBST(FREETYPE2_LIBS)
671 AC_SUBST(PANGO_CFLAGS)
673 AC_SUBST(WAYLAND_CFLAGS)
674 AC_SUBST(WAYLAND_LIBS)
676 AC_CONFIG_FILES([Makefile libeloop.pc libtsm.pc libuterm.pc])
680 # Configuration output
681 # Show configuration to the user so they can check whether everything was
682 # configured as expected.
685 AC_MSG_NOTICE([Build configuration:
687 Applications and libraries:
688 kmscon: $kmscon_enabled
689 wlterm: $wlterm_enabled
690 uterm: $uterm_enabled
691 eloop: $eloop_enabled
694 Miscellaneous options:
695 debug: $debug_enabled
696 optimizations: $optimizations_enabled
698 Optional dependencies:
699 systemd: $systemd_enabled
702 xkbcommon: $xkbcommon_enabled
704 libuterm video backends:
705 fbdev: $fbdev_enabled
706 dumb drm: $dumb_enabled
708 OpenGLES2: $gles2_enabled
711 unifont: $unifont_enabled
713 freetype2: $freetype2_enabled
714 pango: $pango_enabled
717 bblit: $bblit_enabled
718 bbulk: $bbulk_enabled
719 gltex: $gltex_enabled
721 Run "make" to start compilation process])