1dnl Process this file with autoconf to create configure.
2
3AC_PREREQ([2.60])
4
5AC_INIT([virglrenderer], [0.6.0],
6    [virglrenderer-devel@lists.freedesktop.org])
7AC_CONFIG_SRCDIR([Makefile.am])
8AC_CONFIG_HEADERS([config.h])
9AC_CONFIG_AUX_DIR([build-aux])
10AC_CONFIG_MACRO_DIR([build-aux])
11
12AM_INIT_AUTOMAKE([foreign dist-bzip2])
13
14AC_USE_SYSTEM_EXTENSIONS
15AC_PROG_CC_C99
16
17# Support silent build rules, requires at least automake-1.11. Disable
18# by either passing --disable-silent-rules to configure or passing V=1
19# to make
20m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
21    [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
22
23m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
24
25AC_DISABLE_STATIC
26LT_INIT([disable-static])
27AC_SYS_LARGEFILE
28AC_CHECK_PROGS([PYTHON], [python2 python python3])
29AX_CODE_COVERAGE
30
31AX_CHECK_COMPILE_FLAG([-Wall],                                 [CFLAGS="$CFLAGS -Wall"])
32AX_CHECK_COMPILE_FLAG([-Wextra],                               [CFLAGS="$CFLAGS -Wextra"])
33AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration], [CFLAGS="$CFLAGS -Werror=implicit-function-declaration"])
34AX_CHECK_COMPILE_FLAG([-Werror=missing-prototypes],            [CFLAGS="$CFLAGS -Werror=missing-prototypes"])
35AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes],                  [CFLAGS="$CFLAGS -Wmissing-prototypes"])
36AX_CHECK_COMPILE_FLAG([-Werror=int-to-pointer-cast],           [CFLAGS="$CFLAGS -Werror=int-to-pointer-cast"])
37
38AC_MSG_CHECKING([for native Win32])
39case "$host_os" in
40     *mingw*|*cygwin*)
41        os_win32=yes
42        ;;
43     *)
44        os_win32=no
45        ;;
46esac
47AC_MSG_RESULT([$os_win32])
48AM_CONDITIONAL([OS_WIN32],[test "$os_win32" = "yes"])
49
50if test "x$os_win32" = xno; then
51   AX_PTHREAD
52fi
53
54AC_ARG_ENABLE([debug],
55    [AS_HELP_STRING([--enable-debug],
56        [use debug compiler flags and macros @<:@default=disabled@:>@])],
57    [enable_debug="$enableval"],
58    [enable_debug=no]
59)
60if test "x$enable_debug" = xyes; then
61    DEFINES="$DEFINES -DDEBUG"
62    if test "x$GCC" = xyes; then
63        if ! echo "$CFLAGS" | grep -q -e '-g'; then
64            CFLAGS="$CFLAGS -g"
65        fi
66        if ! echo "$CFLAGS" | grep -q -e '-O'; then
67            CFLAGS="$CFLAGS -O0"
68        fi
69    fi
70    if test "x$GXX" = xyes; then
71        if ! echo "$CXXFLAGS" | grep -q -e '-g'; then
72            CXXFLAGS="$CXXFLAGS -g"
73        fi
74        if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
75            CXXFLAGS="$CXXFLAGS -O0"
76        fi
77    fi
78fi
79
80AC_ARG_ENABLE(tests,
81	      AS_HELP_STRING([--enable-tests], [Build the tests (default=auto)]),
82	      [build_tests="$enableval"],
83	      [build_tests="auto"])
84
85AC_ARG_ENABLE([egl], AS_HELP_STRING([--disable-egl], [Disable EGL]))
86
87PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], [HAVE_CHECK="yes"], [HAVE_CHECK="no"])
88
89if test "x$build_tests" = "xauto" && test "x$os_win32" = "xno"; then
90	build_tests="$HAVE_CHECK"
91fi
92if test "x$build_tests" = "xyes"; then
93	if test "x$HAVE_CHECK" = "xno"; then
94		AC_MSG_ERROR([Cannot build tests, check is missing])
95	fi
96
97	AC_PATH_PROG(VALGRIND, [valgrind])
98fi
99
100AC_ARG_ENABLE(fuzzer,
101	      AS_HELP_STRING([--enable-fuzzer], [Build fuzzer targets]),
102	      [enable_fuzzer="$enableval"],
103	      [enable_fuzzer=no]
104)
105AM_CONDITIONAL(FUZZER, [test "x$enable_fuzzer" = "xyes"])
106
107AC_CHECK_FUNCS_ONCE([eventfd])
108AC_CHECK_HEADERS_ONCE([sys/uio.h])
109AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"])
110AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"])
111
112LIBDRM_REQUIRED=2.4.50
113
114if test "x$os_win32" = xno && test "x$enable_egl" != "xno"; then
115	PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
116	PKG_CHECK_MODULES([GBM], [gbm])
117fi
118
119PKG_CHECK_MODULES([EPOXY], [epoxy])
120PKG_CHECK_VAR(epoxy_has_egl, [epoxy], [epoxy_has_egl])
121AS_IF([test "x$epoxy_has_egl" = "x1" && test "x$enable_egl" != "xno"], [
122  epoxy_has_egl=yes
123  AC_DEFINE([HAVE_EPOXY_EGL_H], [1], [Libepoxy has EGL support.])
124],[
125  epoxy_has_egl=no
126])
127AM_CONDITIONAL([HAVE_EPOXY_EGL], [test "x$epoxy_has_egl" = "xyes"])
128
129if test "x$os_win32" = xno; then
130	AS_IF([test "x$epoxy_has_egl" = "x1"], [
131		PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
132		PKG_CHECK_MODULES([GBM], [gbm])
133	])
134fi
135
136
137AM_CONDITIONAL([HAVE_EPOXY_EGL], [test "x$epoxy_has_egl" = "xyes"])
138
139AC_ARG_WITH([glx], AS_HELP_STRING([--with-glx], [Build with the x11/glx backend]))
140AS_IF([test "x$with_glx" = "xyes"], [
141  PKG_CHECK_MODULES([X11], [x11])
142  AC_CHECK_HEADER([epoxy/glx.h])
143])
144AM_CONDITIONAL([WITH_GLX], [test "x$with_glx" = "xyes"])
145
146AC_SUBST([DEFINES])
147AC_CONFIG_FILES([
148		virglrenderer.pc
149		Makefile
150		src/Makefile
151		src/gallium/auxiliary/Makefile
152		vtest/Makefile
153		tests/Makefile
154		tests/fuzzer/Makefile
155])
156AC_OUTPUT
157
158AC_MSG_NOTICE([
159
160      virgl $VERSION
161      ==============
162
163      prefix:                   $prefix
164      c compiler:               $CC
165      win32:                    $os_win32
166
167      glx:                      $with_glx
168      egl:                      $epoxy_has_egl
169      debug:                    $enable_debug
170      tests:                    $build_tests
171      fuzzer:                   $enable_fuzzer
172
173])
174