build: improve gbm_bo_get_stride check
[platform/upstream/kmscon.git] / configure.ac
1 #
2 # Kmscon - build configuration script
3 # Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
4 #
5
6 AC_PREREQ(2.68)
7
8 AC_INIT([kmscon], [3])
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)
14
15 AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects dist-bzip2 no-dist-gzip tar-pax -Wall -Werror])
16 AM_SILENT_RULES([yes])
17
18 #
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.
22 #
23
24 : ${CFLAGS=""}
25
26 AC_USE_SYSTEM_EXTENSIONS
27 AC_PROG_CC
28 AC_PROG_CC_C99
29 AM_PROG_CC_C_O
30 AM_PROG_AR
31
32 LT_PREREQ(2.2)
33 LT_INIT
34
35 #
36 # check for gtk-doc
37 # Use weird syntax to make "gtkdocize" happy.
38 #
39
40 m4_ifdef([GTK_DOC_CHECK],[
41 GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
42 ], [AM_CONDITIONAL([ENABLE_GTK_DOC], false)])
43
44 #
45 # pkg-config dependencies
46 # This unconditionally checks for all dependencies even if they are disabled. We
47 # later look whether all required depedencies are met and finish the
48 # configuration. We group similar packages into one logical group here to avoid
49 # having variables for each single library.
50 # This, however, makes ./configure output very unintuitive error messages if a
51 # package is not found so we must make sure we print more verbose messages
52 # ourself.
53 #
54
55 PKG_CHECK_MODULES([SYSTEMD], [libsystemd-login],
56                   [have_systemd=yes], [have_systemd=no])
57
58 PKG_CHECK_MODULES([UDEV], [libudev],
59                   [have_udev=yes], [have_udev=no])
60
61 PKG_CHECK_MODULES([DBUS], [dbus-1],
62                   [have_dbus=yes], [have_dbus=no])
63
64 PKG_CHECK_MODULES([DRM], [libdrm],
65                   [have_drm=yes], [have_drm=no])
66
67 PKG_CHECK_MODULES([GBM], [gbm],
68                   [have_gbm=yes], [have_gbm=no])
69
70 PKG_CHECK_MODULES([EGL], [egl],
71                   [have_egl=yes], [have_egl=no])
72
73 PKG_CHECK_MODULES([GLES2], [glesv2],
74                   [have_gles2=yes], [have_gles2=no])
75
76 PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon],
77                   [have_xkbcommon=yes], [have_xkbcommon=no])
78
79 PKG_CHECK_MODULES([FREETYPE2], [freetype2 fontconfig],
80                   [have_freetype2=yes], [have_freetype2=no])
81
82 PKG_CHECK_MODULES([PANGO], [pango pangoft2],
83                   [have_pango=yes], [have_pango=no])
84
85 #
86 # Parse arguments
87 # Parse all command line arguments and save the values so we can check them
88 # later when configuring kmscon.
89 #
90
91 AC_MSG_CHECKING([whether to use systemd for multi-seat support])
92 AC_ARG_ENABLE([systemd],
93               [AS_HELP_STRING([--enable-systemd],
94                               [enable multi-seat support with systemd])])
95 AC_MSG_RESULT([ok])
96
97 AC_MSG_CHECKING([whether to use udev for device hotplug support])
98 AC_ARG_ENABLE([udev],
99               [AS_HELP_STRING([--enable-udev],
100                               [enable device hotplug support with udev])])
101 AC_MSG_RESULT([ok])
102
103 AC_MSG_CHECKING([whether to use dbus for IPC])
104 AC_ARG_ENABLE([dbus],
105               [AS_HELP_STRING([--enable-dbus],
106                               [enable dbus IPC])])
107 AC_MSG_RESULT([ok])
108
109 AC_MSG_CHECKING([whether to use uterm fbdev video backend])
110 AC_ARG_ENABLE([fbdev],
111               [AS_HELP_STRING([--enable-fbdev],
112                               [enable uterm fbdev video backend])])
113 AC_MSG_RESULT([ok])
114
115 AC_MSG_CHECKING([whether to use uterm drm video backend])
116 AC_ARG_ENABLE([drm],
117               [AS_HELP_STRING([--enable-drm],
118                               [enable uterm drm video backend])])
119 AC_MSG_RESULT([ok])
120
121 AC_MSG_CHECKING([whether to provide OpenGLES2 support])
122 AC_ARG_ENABLE([gles2],
123               [AS_HELP_STRING([--enable-gles2],
124                               [provide uterm OpenGLES2 support])])
125 AC_MSG_RESULT([ok])
126
127 AC_MSG_CHECKING([whether to use xkbcommon keyboard backend])
128 AC_ARG_ENABLE([xkbcommon],
129               [AS_HELP_STRING([--disable-xkbcommon],
130                               [disable xkbcommon keyboard backend])])
131 AC_MSG_RESULT([ok])
132
133 AC_MSG_CHECKING([whether to use static 8x16 font backend])
134 AC_ARG_ENABLE([f8x16],
135               [AS_HELP_STRING([--disable-f8x16],
136                               [disable static 8x16 font backend])])
137 AC_MSG_RESULT([ok])
138
139 AC_MSG_CHECKING([whether to use freetype2 font backend])
140 AC_ARG_ENABLE([freetype2],
141               [AS_HELP_STRING([--disable-freetype2],
142                               [disable freetype2 font backend])])
143 AC_MSG_RESULT([ok])
144
145 AC_MSG_CHECKING([whether to use pango font backend])
146 AC_ARG_ENABLE([pango],
147               [AS_HELP_STRING([--disable-pango],
148                               [disable pango font backend])])
149 AC_MSG_RESULT([ok])
150
151 AC_MSG_CHECKING([whether to use bblit rendering backend])
152 AC_ARG_ENABLE([bblit],
153               [AS_HELP_STRING([--disable-bblit],
154                               [disable bblit rendering backend])])
155 AC_MSG_RESULT([ok])
156
157 AC_MSG_CHECKING([whether to build with debugging on])
158 AC_ARG_ENABLE([debug],
159               [AS_HELP_STRING([--enable-debug],
160                               [whether to build with debugging on])])
161 AC_MSG_RESULT([ok])
162
163 AC_MSG_CHECKING([whether to disable code optimizations])
164 AC_ARG_ENABLE([optimizations],
165               [AS_HELP_STRING([--disable-optimizations],
166                               [whether to disable code optimizations])])
167 AC_MSG_RESULT([ok])
168
169 #
170 # Debug mode and code optimizations
171 # In debug mode we compile with -g and enable several debug-messages and flags.
172 # With optimizations (default), we add -O2 to compile-flags.
173 #
174
175 debug_enabled=no
176 if test x$enable_debug = xyes ; then
177         debug_enabled=yes
178 fi
179
180 optimizations_enabled=no
181 if test ! x$enable_optimizations = xno ; then
182         optimizations_enabled=yes
183 fi
184
185 if test x$debug_enabled = xyes ; then
186         AC_DEFINE([KMSCON_ENABLE_DEBUG], [1],
187                   [Enable debug for kmscon])
188         AC_DEFINE([LOG_ENABLE_DEBUG], [1],
189                   [Enable debug for log subsystem])
190         AC_DEFINE([LLOG_ENABLE_DEBUG], [1],
191                   [Enable debug for llog subsystem])
192 else
193         AC_DEFINE([NDEBUG], [1], [No Debug])
194 fi
195
196 AM_CONDITIONAL([DEBUG], [test x$debug_enabled = xyes])
197 AM_CONDITIONAL([OPTIMIZATIONS], [test x$optimizations_enabled = xyes])
198
199 #
200 # Main dependencies
201 # This checks for all dependencies that are not optional.
202 #
203
204 # We currently have no mandatory dependencies!
205
206 #
207 # Systemd dependency
208 # We can optionally use systemd for multi-seat support. If systemd is not
209 # available or the system was not started with systemd, we simply fall back to
210 # single-seat mode.
211 #
212
213 systemd_enabled=no
214 if test ! x$enable_systemd = xno ; then
215         if test x$have_systemd = xyes ; then
216                 systemd_enabled=yes
217         elif test x$enable_systemd = xyes ; then
218                 AC_ERROR([systemd libraries not found for multi-seat support])
219         fi
220 fi
221
222 if test x$systemd_enabled = xyes ; then
223         AC_DEFINE([UTERM_HAVE_SYSTEMD], [1],
224                   [Use systemd for multi-seat support])
225 else
226         SYSTEMD_CFLAGS=""
227         SYSTEMD_LIBS=""
228 fi
229
230 #
231 # Udev dependency
232 # For hotplugging support we need udev to notify us about system events. If udev
233 # is not available, we simply fall back to static mode. Periodic scanning is
234 # also supported.
235 #
236
237 udev_enabled=no
238 if test ! x$enable_udev = xno ; then
239         if test x$have_udev = xyes ; then
240                 udev_enabled=yes
241         elif test x$enable_udev = xyes ; then
242                 AC_ERROR([udev libraries not found for device hotplug support])
243         fi
244 fi
245
246 if test x$udev_enabled = xyes ; then
247         AC_DEFINE([UTERM_HAVE_UDEV], [1],
248                   [Use udev for device hotplug support])
249 else
250         UDEV_CFLAGS=""
251         UDEV_LIBS=""
252 fi
253
254 #
255 # DBus dependency
256 # For IPC mechanisms we use DBus. Especially multi-seat enabled multi-session
257 # capable applications need DBus to manage application and terminal switching.
258 #
259
260 dbus_enabled=no
261 if test ! x$enable_dbus = xno ; then
262         if test x$have_dbus = xyes ; then
263                 dbus_enabled=yes
264         elif test x$enable_dbus = xyes; then
265                 AC_ERROR([dbus libraries not found])
266         fi
267 fi
268
269 if test x$dbus_enabled = xyes; then
270         AC_DEFINE([EV_HAVE_DBUS], [1],
271                   [Use dbus for IPC])
272 else
273         DBUS_CFLAGS=""
274         DBUS_LIBS=""
275 fi
276
277 AM_CONDITIONAL([EV_HAVE_DBUS], [test x$dbus_enabled = xyes])
278
279 #
280 # Uterm fbdev backend
281 # This checks whether the fbdev backend was requested and enables it then. There
282 # are no special dependencies for it except the kernel headers.
283 # TODO: check for kernel headers here
284 #
285
286 fbdev_enabled=no
287 if test ! x$enable_fbdev = xno ; then
288         fbdev_enabled=yes
289 fi
290
291 if test x$fbdev_enabled = xyes ; then
292         AC_DEFINE([UTERM_HAVE_FBDEV], [1],
293                   [Use uterm fbdev video backend])
294 fi
295
296 AM_CONDITIONAL([UTERM_HAVE_FBDEV], [test x$fbdev_enabled = xyes])
297
298 #
299 # Uterm drm backend
300 # This checks whether libdrm is available and some combination of libgbm, egl
301 # and gl or glesv2. If it is not available, then the drm backend is simply not
302 # built.
303 #
304
305 dumb_enabled=no
306 drm_enabled=no
307 gles2_enabled=no
308 if test ! x$enable_drm = xno ; then
309         if test x$have_drm = xyes ; then
310                 dumb_enabled=yes
311         fi
312
313         if test ! x$enable_gles2 = xno ; then
314                 if test x$have_drm = xyes -a x$have_gbm = xyes -a x$have_egl = xyes ; then
315                         if test x$have_gles2 = xyes ; then
316                                 drm_enabled=yes
317                                 gles2_enabled=yes
318                         fi
319                 fi
320         fi
321
322         if test x$enable_drm = xyes -a x$dumb_enabled = xno ; then
323                 AC_ERROR([drm library not found for uterm dumb drm backend])
324         fi
325
326         if test x$enable_gles2 = xyes -a x$drm_enabled = xno ; then
327                 AC_ERROR([drm, gbm, egl, gl or gles2 libraries not found for uterm drm backend])
328         fi
329 fi
330
331 if test x$dumb_enabled = xyes ; then
332         AC_DEFINE([UTERM_HAVE_DUMB], [1],
333                   [Use uterm dumb drm video backend])
334
335         if test x$drm_enabled = xyes ; then
336                 AC_DEFINE([UTERM_HAVE_DRM], [1],
337                           [Use uterm DRM video backend])
338         else
339                 GBM_CFLAGS=""
340                 GBM_LIBS=""
341                 EGL_CFLAGS=""
342                 EGL_LIBS=""
343         fi
344 else
345         DRM_CFLAGS=""
346         DRM_LIBS=""
347         GBM_CFLAGS=""
348         GBM_LIBS=""
349         EGL_CFLAGS=""
350         EGL_LIBS=""
351 fi
352
353 if test x$gles2_enabled = xyes ; then
354         AC_DEFINE([KMSCON_HAVE_GLES2], [1],
355                   [Use OpenGLESv2 as drawing backend])
356 else
357         GLES2_CFLAGS=""
358         GLES2_LIBS=""
359 fi
360
361 AM_CONDITIONAL([UTERM_HAVE_DUMB], [test x$dumb_enabled = xyes])
362 AM_CONDITIONAL([UTERM_HAVE_DRM], [test x$drm_enabled = xyes])
363 AM_CONDITIONAL([KMSCON_HAVE_GLES2], [test x$gles2_enabled = xyes])
364
365 if test x$have_gbm = xyes ; then
366         save_CFLAGS="$CFLAGS"
367         save_LIBS="$LIBS"
368         CFLAGS=$GBM_CFLAGS
369         LIBS=$GBM_LIBS
370         AC_CHECK_LIB([gbm],
371                      [gbm_bo_get_stride],
372                      [AC_DEFINE([HAVE_GBM_BO_GET_STRIDE],
373                                 [1],
374                                 [Define to 1 if your libgbm provides gbm_bo_get_stride])])
375         CFLAGS="$save_CFLAGS"
376         LIBS="$save_LIBS"
377 fi
378
379 #
380 # xkbcommon keyboard backend
381 # This checks for the xkbcommon library for keyboard handling in uterm. If it is
382 # not available, we use a dumb-keyboard backend as fall-back.
383 #
384
385 xkbcommon_enabled=no
386 if test ! x$enable_xkbcommon = xno ; then
387         if test x$have_xkbcommon = xyes ; then
388                 xkbcommon_enabled=yes
389         elif test x$enable_xkbcommon = xyes ; then
390                 AC_ERROR([xkbcommon not found for keyboard backend])
391         fi
392 fi
393
394 if test x$xkbcommon_enabled = xyes ; then
395         AC_DEFINE([UTERM_HAVE_XKBCOMMON], [1],
396                   [Use xkbcommon as input keyboard handling backend])
397 else
398         XKBCOMMON_CFLAGS=""
399         XKBCOMMON_LIBS=""
400 fi
401
402 AM_CONDITIONAL([UTERM_HAVE_XKBCOMMON], [test x$xkbcommon_enabled = xyes])
403
404 #
405 # Font backends
406 # This checks for the 8x16, freetype2 and pango font backends and enables them
407 # if requested and available.
408 #
409
410 f8x16_enabled=no
411 if test ! x$enable_f8x16 = xno ; then
412         f8x16_enabled=yes
413 fi
414
415 if test x$f8x16_enabled = xyes ; then
416         AC_DEFINE([KMSCON_HAVE_8X16], [1],
417                   [Use static 8x16 font backend])
418 fi
419
420 AM_CONDITIONAL([KMSCON_HAVE_8X16], [test x$f8x16_enabled = xyes])
421
422 freetype2_enabled=no
423 if test ! x$enable_freetype2 = xno ; then
424         if test x$have_freetype2 = xyes ; then
425                 freetype2_enabled=yes
426         elif test x$enable_freetype2 = xyes ; then
427                 AC_ERROR([freetype2/fontconfig not found for freetype2 backend])
428         fi
429 fi
430
431 if test x$freetype2_enabled = xyes ; then
432         AC_DEFINE([KMSCON_HAVE_FREETYPE2], [1],
433                   [Use freetype2 as font backend])
434 else
435         FREETYPE2_CFLAGS=""
436         FREETYPE2_LIBS=""
437 fi
438
439 AM_CONDITIONAL([KMSCON_HAVE_FREETYPE2], [test x$freetype2_enabled = xyes])
440
441 pango_enabled=no
442 if test ! x$enable_pango = xno ; then
443         if test x$have_pango = xyes ; then
444                 pango_enabled=yes
445         elif test x$enable_pango = xyes ; then
446                 AC_ERROR([pango not found for pango font backend])
447         fi
448 fi
449
450 if test x$pango_enabled = xyes ; then
451         AC_DEFINE([KMSCON_HAVE_PANGO], [1],
452                   [Use pango as font backend])
453 else
454         PANGO_CFLAGS=""
455         PANGO_LIBS=""
456 fi
457
458 AM_CONDITIONAL([KMSCON_HAVE_PANGO], [test x$pango_enabled = xyes])
459
460 #
461 # BBlit Rendering backend
462 #
463
464 bblit_enabled=no
465 if test ! x$enable_bblit = xno ; then
466         bblit_enabled=yes
467 fi
468
469 if test x$bblit_enabled = xyes ; then
470         AC_DEFINE([KMSCON_HAVE_BBLIT], [1],
471                   [Use bblit rendering backend])
472 fi
473
474 AM_CONDITIONAL([KMSCON_HAVE_BBLIT], [test x$bblit_enabled = xyes])
475
476 #
477 # OpenGL Texture rendering backend
478 # This is not really an option but automatically enabled if OpenGLES2 support
479 # was selected.
480 #
481
482 gltex_enabled=no
483 if test x$gles2_enabled = xyes ; then
484         gltex_enabled=yes
485 fi
486
487 #
488 # Makefile vars
489 # After everything is configured, we correctly substitute the values for the
490 # makefiles.
491 #
492
493 AC_SUBST(SYSTEMD_CFLAGS)
494 AC_SUBST(SYSTEMD_LIBS)
495 AC_SUBST(DBUS_CFLAGS)
496 AC_SUBST(DBUS_LIBS)
497 AC_SUBST(DRM_CFLAGS)
498 AC_SUBST(DRM_LIBS)
499 AC_SUBST(EGL_CFLAGS)
500 AC_SUBST(EGL_LIBS)
501 AC_SUBST(GBM_CFLAGS)
502 AC_SUBST(GBM_LIBS)
503 AC_SUBST(GLES2_CFLAGS)
504 AC_SUBST(GLES2_LIBS)
505 AC_SUBST(UDEV_CFLAGS)
506 AC_SUBST(UDEV_LIBS)
507 AC_SUBST(XKBCOMMON_CFLAGS)
508 AC_SUBST(XKBCOMMON_LIBS)
509 AC_SUBST(FREETYPE2_CFLAGS)
510 AC_SUBST(FREETYPE2_LIBS)
511 AC_SUBST(PANGO_CFLAGS)
512 AC_SUBST(PANGO_LIBS)
513
514 AC_CONFIG_FILES([Makefile docs/reference/Makefile docs/reference/version.xml])
515 AC_OUTPUT([src/genshader.c])
516
517 #
518 # Configuration output
519 # Show configuration to the user so they can check whether everything was
520 # configured as expected.
521 #
522
523 AC_MSG_NOTICE([Build configuration:
524
525                 debug: $debug_enabled
526         optimizations: $optimizations_enabled
527
528               systemd: $systemd_enabled
529                  udev: $udev_enabled
530                  dbus: $dbus_enabled
531             xkbcommon: $xkbcommon_enabled
532
533   libuterm video backends:
534                 fbdev: $fbdev_enabled
535              dumb drm: $dumb_enabled
536                   drm: $drm_enabled
537             OpenGLES2: $gles2_enabled
538
539   font backends:
540                  8x16: $f8x16_enabled
541             freetype2: $freetype2_enabled
542                 pango: $pango_enabled
543
544   rendering backends:
545                 bblit: $bblit_enabled
546                 gltex: $gltex_enabled
547
548         Run "make" to start compilation process])