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/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
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 xkbcommon keyboard backend])
158 AC_ARG_ENABLE([xkbcommon],
159 [AS_HELP_STRING([--disable-xkbcommon],
160 [disable xkbcommon keyboard backend])])
163 AC_MSG_CHECKING([whether to use static unifont backend])
164 AC_ARG_ENABLE([unifont],
165 [AS_HELP_STRING([--enable-unifont],
166 [enable static unifont font backend (GPL)])])
169 AC_MSG_CHECKING([whether to use static 8x16 font backend])
170 AC_ARG_ENABLE([f8x16],
171 [AS_HELP_STRING([--disable-f8x16],
172 [disable static 8x16 font backend])])
175 AC_MSG_CHECKING([whether to use freetype2 font backend])
176 AC_ARG_ENABLE([freetype2],
177 [AS_HELP_STRING([--disable-freetype2],
178 [disable freetype2 font backend])])
181 AC_MSG_CHECKING([whether to use pango font backend])
182 AC_ARG_ENABLE([pango],
183 [AS_HELP_STRING([--disable-pango],
184 [disable pango font backend])])
187 AC_MSG_CHECKING([whether to use bblit rendering backend])
188 AC_ARG_ENABLE([bblit],
189 [AS_HELP_STRING([--disable-bblit],
190 [disable bblit rendering backend])])
193 AC_MSG_CHECKING([whether to use bbulk rendering backend])
194 AC_ARG_ENABLE([bbulk],
195 [AS_HELP_STRING([--disable-bbulk],
196 [disable bbulk rendering backend])])
200 # Parse miscellaneous arguments
201 # These don't belong into the categories above for several reason so they are
203 # They configure compiler options and similar.
206 AC_MSG_CHECKING([whether to build with debugging on])
207 AC_ARG_ENABLE([debug],
208 [AS_HELP_STRING([--enable-debug],
209 [whether to build with debugging on])])
212 AC_MSG_CHECKING([whether to disable code optimizations])
213 AC_ARG_ENABLE([optimizations],
214 [AS_HELP_STRING([--disable-optimizations],
215 [whether to disable code optimizations])])
219 # Debug mode and code optimizations
220 # In debug mode we compile with -g and enable several debug-messages and flags.
221 # With optimizations (default), we add -O2 to compile-flags.
225 if test x$enable_debug = xyes ; then
229 optimizations_enabled=no
230 if test ! x$enable_optimizations = xno ; then
231 optimizations_enabled=yes
234 if test x$debug_enabled = xyes ; then
235 AC_DEFINE([BUILD_ENABLE_DEBUG], [1],
238 AC_DEFINE([NDEBUG], [1], [No Debug])
241 AM_CONDITIONAL([BUILD_ENABLE_DEBUG],
242 [test x$debug_enabled = xyes])
243 AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
244 [test x$optimizations_enabled = xyes])
246 # check for _Static_assert
247 AC_MSG_CHECKING([whether _Static_assert() is supported])
249 have_static_assert=yes
250 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[_Static_assert(1, "What?");]])],
251 [AC_DEFINE([BUILD_HAVE_STATIC_ASSERT],
253 [Define to 1 if _Static_assert() is supported])],
254 [have_static_assert=no])
255 AC_MSG_RESULT([$have_static_assert])
259 # This checks which applications to build so we can optionally disable unused
260 # dependencies below.
262 # Dependency Calculations
263 # The first thing we do is checking which applications to build. Then we
264 # forcibly enable all libraries that are needed by these and then we forcibly
265 # enable all other source-code dependecies.
267 # The "enable_XY" flag is user input that is set to "yes" if they enabled it
268 # explicitly, "no" if they disabled it explicitly or "" (empty) if they did
269 # not specify it explicitly. In the latter case we enable it if all dependencies
270 # are met, otherwise, we disable it. This does not work for applications,
271 # though. If an application is not specified explicitly by the user, then we
272 # force the default value.
273 # An application also forces all _hard_ dependencies to "yes" and so fails if
274 # they cannot be met.
278 if test ! x$enable_kmscon = xno ; then
285 AM_CONDITIONAL([BUILD_ENABLE_KMSCON],
286 [test x$kmscon_enabled = xyes])
289 if test x$enable_wlterm = xyes ; then
297 AM_CONDITIONAL([BUILD_ENABLE_WLTERM],
298 [test x$wlterm_enabled = xyes])
301 if test x$enable_uterm = xyes ; then
306 AM_CONDITIONAL([BUILD_ENABLE_UTERM],
307 [test x$uterm_enabled = xyes])
310 if test x$enable_eloop = xyes ; then
314 AM_CONDITIONAL([BUILD_ENABLE_ELOOP],
315 [test x$eloop_enabled = xyes])
318 if test x$enable_tsm = xyes ; then
322 AM_CONDITIONAL([BUILD_ENABLE_TSM],
323 [test x$tsm_enabled = xyes])
327 # We can optionally use systemd for multi-seat support. If systemd is not
328 # available or the system was not started with systemd, we simply fall back to
333 if test ! x$enable_systemd = xno ; then
334 if test x$have_systemd = xyes ; then
336 elif test x$enable_systemd = xyes ; then
337 AC_ERROR([systemd libraries not found for multi-seat support])
341 if test x$systemd_enabled = xyes ; then
342 AC_DEFINE([BUILD_ENABLE_SYSTEMD], [1],
343 [Use systemd for multi-seat support])
351 # For hotplugging support we need udev to notify us about system events. If udev
352 # is not available, we simply fall back to static mode. Periodic scanning is
357 if test ! x$enable_udev = xno ; then
358 if test x$have_udev = xyes ; then
360 elif test x$enable_udev = xyes ; then
361 AC_ERROR([udev libraries not found for device hotplug support])
365 if test x$udev_enabled = xyes ; then
366 AC_DEFINE([BUILD_ENABLE_UDEV], [1],
367 [Use udev for device hotplug support])
375 # For IPC mechanisms we use DBus. Especially multi-seat enabled multi-session
376 # capable applications need DBus to manage application and terminal switching.
380 if test x$enable_dbus = xyes ; then
381 if test x$have_dbus = xyes ; then
383 elif test x$enable_dbus = xyes; then
384 AC_ERROR([dbus libraries not found])
388 if test x$dbus_enabled = xyes; then
389 AC_DEFINE([BUILD_ENABLE_DBUS], [1],
396 AM_CONDITIONAL([BUILD_ENABLE_DBUS], [test x$dbus_enabled = xyes])
399 # Uterm fbdev backend
400 # This checks whether the fbdev backend was requested and enables it then. There
401 # are no special dependencies for it except the kernel headers.
402 # TODO: check for kernel headers here
406 if test ! x$enable_fbdev = xno ; then
410 if test x$fbdev_enabled = xyes ; then
411 AC_DEFINE([BUILD_ENABLE_FBDEV], [1],
412 [Use uterm fbdev video backend])
415 AM_CONDITIONAL([BUILD_ENABLE_FBDEV], [test x$fbdev_enabled = xyes])
419 # This checks whether libdrm is available and some combination of libgbm, egl
420 # and gl or glesv2. If it is not available, then the drm backend is simply not
427 if test ! x$enable_drm = xno ; then
428 if test x$have_drm = xyes ; then
432 if test ! x$enable_gles2 = xno ; then
433 if test x$have_drm = xyes -a x$have_gbm = xyes -a x$have_egl = xyes ; then
434 if test x$have_gles2 = xyes ; then
441 if test x$enable_drm = xyes -a x$dumb_enabled = xno ; then
442 AC_ERROR([drm library not found for uterm dumb drm backend])
445 if test x$enable_gles2 = xyes -a x$drm_enabled = xno ; then
446 AC_ERROR([drm, gbm, egl, gl or gles2 libraries not found for uterm drm backend])
450 if test x$dumb_enabled = xyes ; then
451 AC_DEFINE([BUILD_ENABLE_DUMB], [1],
452 [Use uterm dumb drm video backend])
454 if test x$drm_enabled = xyes ; then
455 AC_DEFINE([BUILD_ENABLE_DRM], [1],
456 [Use uterm DRM video backend])
472 if test x$gles2_enabled = xyes ; then
473 AC_DEFINE([BUILD_ENABLE_GLES2], [1],
474 [Use OpenGLESv2 as drawing backend])
480 AM_CONDITIONAL([BUILD_ENABLE_DUMB], [test x$dumb_enabled = xyes])
481 AM_CONDITIONAL([BUILD_ENABLE_DRM], [test x$drm_enabled = xyes])
482 AM_CONDITIONAL([BUILD_ENABLE_GLES2], [test x$gles2_enabled = xyes])
484 # check for gbm_bo_get_stride() function, otherwise gbm_bo_get_pitch() is used
485 if test x$have_gbm = xyes ; then
486 save_CFLAGS="$CFLAGS"
488 CFLAGS="$CFLAGS $GBM_CFLAGS $DRM_CFLAGS"
489 LIBS="$LIBS $GBM_LIBS $DRM_LIBS"
492 [AC_DEFINE([BUILD_HAVE_GBM_BO_GET_STRIDE],
494 [Define to 1 if your libgbm provides gbm_bo_get_stride])])
495 CFLAGS="$save_CFLAGS"
500 # xkbcommon keyboard backend
501 # This checks for the xkbcommon library for keyboard handling in uterm. If it is
502 # not available, we use a dumb-keyboard backend as fall-back.
506 if test ! x$enable_xkbcommon = xno ; then
507 if test x$have_xkbcommon = xyes ; then
508 xkbcommon_enabled=yes
509 elif test x$enable_xkbcommon = xyes ; then
510 AC_ERROR([xkbcommon not found for keyboard backend])
514 if test x$xkbcommon_enabled = xyes ; then
515 AC_DEFINE([BUILD_ENABLE_XKBCOMMON], [1],
516 [Use xkbcommon as input keyboard handling backend])
522 AM_CONDITIONAL([BUILD_ENABLE_XKBCOMMON], [test x$xkbcommon_enabled = xyes])
526 # This checks for the unifont, 8x16, freetype2 and pango font backends and
527 # enables them if requested and available.
529 # Please note that the Unifont-data is GPL'ed and we compile this statically
530 # into our application. I do not consider this a "derivative" but a lawyer may
531 # disagree. So please make sure you enable this only if you use the GPL as
532 # license for kmscon.
536 if test x$enable_unifont = xyes ; then
540 if test x$unifont_enabled = xyes ; then
541 AC_DEFINE([BUILD_ENABLE_UNIFONT], [1],
542 [Use static unifont backend])
545 AM_CONDITIONAL([BUILD_ENABLE_UNIFONT], [test x$unifont_enabled = xyes])
548 if test ! x$enable_f8x16 = xno ; then
552 if test x$f8x16_enabled = xyes ; then
553 AC_DEFINE([BUILD_ENABLE_8X16], [1],
554 [Use static 8x16 font backend])
557 AM_CONDITIONAL([BUILD_ENABLE_8X16], [test x$f8x16_enabled = xyes])
560 if test ! x$enable_freetype2 = xno ; then
561 if test x$have_freetype2 = xyes ; then
562 freetype2_enabled=yes
563 elif test x$enable_freetype2 = xyes ; then
564 AC_ERROR([freetype2/fontconfig not found for freetype2 backend])
568 if test x$freetype2_enabled = xyes ; then
569 AC_DEFINE([BUILD_ENABLE_FREETYPE2], [1],
570 [Use freetype2 as font backend])
576 AM_CONDITIONAL([BUILD_ENABLE_FREETYPE2], [test x$freetype2_enabled = xyes])
579 if test ! x$enable_pango = xno ; then
580 if test x$have_pango = xyes ; then
582 elif test x$enable_pango = xyes ; then
583 AC_ERROR([pango not found for pango font backend])
587 if test x$pango_enabled = xyes ; then
588 AC_DEFINE([BUILD_ENABLE_PANGO], [1],
589 [Use pango as font backend])
595 AM_CONDITIONAL([BUILD_ENABLE_PANGO], [test x$pango_enabled = xyes])
598 # BBlit Rendering backend
602 if test ! x$enable_bblit = xno ; then
606 if test x$bblit_enabled = xyes ; then
607 AC_DEFINE([BUILD_ENABLE_BBLIT], [1],
608 [Use bblit rendering backend])
611 AM_CONDITIONAL([BUILD_ENABLE_BBLIT], [test x$bblit_enabled = xyes])
614 # BBulk Rendering backend
618 if test ! x$enable_bbulk = xno ; then
622 if test x$bbulk_enabled = xyes ; then
623 AC_DEFINE([BUILD_ENABLE_BBULK], [1],
624 [Use bbulk rendering backend])
627 AM_CONDITIONAL([BUILD_ENABLE_BBULK], [test x$bbulk_enabled = xyes])
630 # OpenGL Texture rendering backend
631 # This is not really an option but automatically enabled if OpenGLES2 support
636 if test x$gles2_enabled = xyes ; then
642 # This checks whether the wayland libraries are needed and available.
646 if test ! x$enable_wayland = xno ; then
647 if test x$have_wayland = xyes ; then
649 elif test x$enable_wayland = xyes ; then
650 AC_ERROR([wayland libraries not found])
654 if test x$wayland_enabled = xyes ; then
655 AC_DEFINE([BUILD_ENABLE_WAYLAND], [1],
656 [Enable wayland backends])
664 # After everything is configured, we correctly substitute the values for the
668 AC_SUBST(SYSTEMD_CFLAGS)
669 AC_SUBST(SYSTEMD_LIBS)
670 AC_SUBST(DBUS_CFLAGS)
678 AC_SUBST(GLES2_CFLAGS)
680 AC_SUBST(UDEV_CFLAGS)
682 AC_SUBST(XKBCOMMON_CFLAGS)
683 AC_SUBST(XKBCOMMON_LIBS)
684 AC_SUBST(FREETYPE2_CFLAGS)
685 AC_SUBST(FREETYPE2_LIBS)
686 AC_SUBST(PANGO_CFLAGS)
688 AC_SUBST(WAYLAND_CFLAGS)
689 AC_SUBST(WAYLAND_LIBS)
691 AC_CONFIG_FILES([Makefile libeloop.pc libtsm.pc libuterm.pc])
695 # Configuration output
696 # Show configuration to the user so they can check whether everything was
697 # configured as expected.
700 AC_MSG_NOTICE([Build configuration:
702 Applications and libraries:
703 kmscon: $kmscon_enabled
704 wlterm: $wlterm_enabled
705 uterm: $uterm_enabled
706 eloop: $eloop_enabled
709 Miscellaneous options:
710 debug: $debug_enabled
711 optimizations: $optimizations_enabled
713 Optional dependencies:
714 systemd: $systemd_enabled
717 xkbcommon: $xkbcommon_enabled
719 libuterm video backends:
720 fbdev: $fbdev_enabled
721 dumb drm: $dumb_enabled
723 OpenGLES2: $gles2_enabled
726 unifont: $unifont_enabled
728 freetype2: $freetype2_enabled
729 pango: $pango_enabled
732 bblit: $bblit_enabled
733 bbulk: $bbulk_enabled
734 gltex: $gltex_enabled
736 Run "make" to start compilation process])