ff2c840127c954e14c66949cef9108e91d173859
[glsdk/libdrm.git] / configure.ac
1 #  Copyright 2005 Adam Jackson.
2 #
3 #  Permission is hereby granted, free of charge, to any person obtaining a
4 #  copy of this software and associated documentation files (the "Software"),
5 #  to deal in the Software without restriction, including without limitation
6 #  on the rights to use, copy, modify, merge, publish, distribute, sub
7 #  license, and/or sell copies of the Software, and to permit persons to whom
8 #  the Software is furnished to do so, subject to the following conditions:
9 #
10 #  The above copyright notice and this permission notice (including the next
11 #  paragraph) shall be included in all copies or substantial portions of the
12 #  Software.
13 #
14 #  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 #  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 #  FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
17 #  ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 #  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 AC_PREREQ([2.63])
22 AC_INIT([libdrm],
23         [2.4.32],
24         [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI],
25         [libdrm])
27 AC_CONFIG_HEADERS([config.h])
28 AC_CONFIG_SRCDIR([Makefile.am])
29 AC_CONFIG_MACRO_DIR([m4])
30 AC_CONFIG_AUX_DIR([build-aux])
32 AM_INIT_AUTOMAKE([1.10 foreign dist-bzip2])
33 AM_MAINTAINER_MODE([enable])
35 # Enable quiet compiles on automake 1.11.
36 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
38 # Check for programs
39 AC_PROG_CC
41 AC_USE_SYSTEM_EXTENSIONS
42 AC_SYS_LARGEFILE
43 AC_FUNC_ALLOCA
45 # Initialize libtool
46 LT_PREREQ([2.2])
47 LT_INIT([disable-static])
50 PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs)
51 AC_SUBST(PTHREADSTUBS_CFLAGS)
52 AC_SUBST(PTHREADSTUBS_LIBS)
54 pkgconfigdir=${libdir}/pkgconfig
55 AC_SUBST(pkgconfigdir)
56 AC_ARG_ENABLE([udev],
57               [AS_HELP_STRING([--enable-udev],
58                               [Enable support for using udev instead of mknod (default: disabled)])],
59               [UDEV=$enableval], [UDEV=no])
61 AC_ARG_ENABLE(libkms,
62               AS_HELP_STRING([--disable-libkms],
63               [Disable KMS mm abstraction library (default: auto)]),
64               [LIBKMS=$enableval], [LIBKMS=auto])
66 AC_ARG_ENABLE(intel,
67               AS_HELP_STRING([--disable-intel],
68               [Enable support for intel's KMS API (default: auto)]),
69               [INTEL=$enableval], [INTEL=auto])
71 AC_ARG_ENABLE(radeon,
72               AS_HELP_STRING([--disable-radeon],
73               [Enable support for radeon's KMS API (default: auto)]),
74               [RADEON=$enableval], [RADEON=auto])
76 AC_ARG_ENABLE(vmwgfx-experimental-api,
77               AS_HELP_STRING([--enable-vmwgfx-experimental-api],
78               [Install vmwgfx's experimental kernel API header (default: disabled)]),
79               [VMWGFX=$enableval], [VMWGFX=no])
81 AC_ARG_ENABLE(nouveau-experimental-api,
82               AS_HELP_STRING([--enable-nouveau-experimental-api],
83               [Enable support for nouveau's experimental API (default: disabled)]),
84               [NOUVEAU=$enableval], [NOUVEAU=no])
87 dnl ===========================================================================
88 dnl check compiler flags
89 AC_DEFUN([LIBDRM_CC_TRY_FLAG], [
90   AC_MSG_CHECKING([whether $CC supports $1])
92   libdrm_save_CFLAGS="$CFLAGS"
93   CFLAGS="$CFLAGS $1"
95   AC_COMPILE_IFELSE([ ], [libdrm_cc_flag=yes], [libdrm_cc_flag=no])
96   CFLAGS="$libdrm_save_CFLAGS"
98   if test "x$libdrm_cc_flag" = "xyes"; then
99     ifelse([$2], , :, [$2])
100   else
101     ifelse([$3], , :, [$3])
102   fi
103   AC_MSG_RESULT([$libdrm_cc_flag])
104 ])
106 dnl We use clock_gettime to check for timeouts in drmWaitVBlank
108 AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
109                [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
110                              [AC_MSG_ERROR([Couldn't find clock_gettime])])])
111 AC_SUBST([CLOCK_LIB])
113 AC_CHECK_FUNCS([open_memstream], [HAVE_OPEN_MEMSTREAM=yes])
115 dnl Use lots of warning flags with with gcc and compatible compilers
117 dnl Note: if you change the following variable, the cache is automatically
118 dnl skipped and all flags rechecked.  So there's no need to do anything
119 dnl else.  If for any reason you need to force a recheck, just change
120 dnl MAYBE_WARN in an ignorable way (like adding whitespace)
122 MAYBE_WARN="-Wall -Wextra \
123 -Wsign-compare -Werror-implicit-function-declaration \
124 -Wpointer-arith -Wwrite-strings -Wstrict-prototypes \
125 -Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
126 -Wpacked -Wswitch-enum -Wmissing-format-attribute \
127 -Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
128 -Wdeclaration-after-statement -Wold-style-definition \
129 -Wno-missing-field-initializers -Wno-unused-parameter \
130 -Wno-attributes -Wno-long-long -Winline"
132 # invalidate cached value if MAYBE_WARN has changed
133 if test "x$libdrm_cv_warn_maybe" != "x$MAYBE_WARN"; then
134         unset libdrm_cv_warn_cflags
135 fi
136 AC_CACHE_CHECK([for supported warning flags], libdrm_cv_warn_cflags, [
137         echo
138         WARN_CFLAGS=""
140         # Some warning options are not supported by all versions of
141         # gcc, so test all desired options against the current
142         # compiler.
143         #
144         # Note that there are some order dependencies
145         # here. Specifically, an option that disables a warning will
146         # have no net effect if a later option then enables that
147         # warnings, (perhaps implicitly). So we put some grouped
148         # options (-Wall and -Wextra) up front and the -Wno options
149         # last.
151         for W in $MAYBE_WARN; do
152                 LIBDRM_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
153         done
155         libdrm_cv_warn_cflags=$WARN_CFLAGS
156         libdrm_cv_warn_maybe=$MAYBE_WARN
158         AC_MSG_CHECKING([which warning flags were supported])])
159 WARN_CFLAGS="$libdrm_cv_warn_cflags"
161 if test "x$UDEV" = xyes; then
162         AC_DEFINE(UDEV, 1, [Have UDEV support])
163 fi
165 AC_CANONICAL_HOST
166 if test "x$LIBKMS" = xauto ; then
167         case $host_os in
168                 linux*)         LIBKMS="yes" ;;
169                 *)              LIBKMS="no" ;;
170         esac
171 fi
173 AM_CONDITIONAL(HAVE_LIBKMS, [test "x$LIBKMS" = xyes])
175 AM_CONDITIONAL(HAVE_VMWGFX, [test "x$VMWGFX" = xyes])
176 if test "x$VMWGFX" = xyes; then
177         AC_DEFINE(HAVE_VMWGFX, 1, [Have vmwgfx kernel headers])
178 fi
180 AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
181 if test "x$NOUVEAU" = xyes; then
182         AC_DEFINE(HAVE_NOUVEAU, 1, [Have nouveau (nvidia) support])
183 fi
185 PKG_CHECK_MODULES(CAIRO, cairo, [HAVE_CAIRO=yes], [HAVE_CAIRO=no])
186 if test "x$HAVE_CAIRO" = xyes; then
187         AC_DEFINE(HAVE_CAIRO, 1, [Have cairo support])
188 fi
189 AM_CONDITIONAL(HAVE_CAIRO, [test "x$HAVE_CAIRO" = xyes])
191 # For enumerating devices in test case
192 PKG_CHECK_MODULES(LIBUDEV, libudev, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no])
193 if test "x$HAVE_LIBUDEV" = xyes; then
194         AC_DEFINE(HAVE_LIBUDEV, 1, [Have libudev support])
195 fi
196 AM_CONDITIONAL(HAVE_LIBUDEV, [test "x$HAVE_LIBUDEV" = xyes])
198 if test "x$INTEL" != "xno" -o "x$RADEON" != "xno"; then
199     # Check for atomic intrinsics
200     AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives,
201     [
202             drm_cv_atomic_primitives="none"
204             AC_LINK_IFELSE([AC_LANG_PROGRAM([[
205     int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }
206     int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i, j, k); }
207                                             ]],[[]])],
208                            [drm_cv_atomic_primitives="Intel"],[])
210             if test "x$drm_cv_atomic_primitives" = "xnone"; then
211                     AC_CHECK_HEADER([atomic_ops.h], drm_cv_atomic_primitives="libatomic-ops")
212             fi
214             # atomic functions defined in <atomic.h> & libc on Solaris
215             if test "x$drm_cv_atomic_primitives" = "xnone"; then
216                     AC_CHECK_FUNC([atomic_cas_uint],
217                                   drm_cv_atomic_primitives="Solaris")
218             fi
220     ])
221     if test "x$drm_cv_atomic_primitives" = xIntel; then
222             AC_DEFINE(HAVE_LIBDRM_ATOMIC_PRIMITIVES, 1,
223                       [Enable if your compiler supports the Intel __sync_* atomic primitives])
224     fi
225     if test "x$drm_cv_atomic_primitives" = "xlibatomic-ops"; then
226             AC_DEFINE(HAVE_LIB_ATOMIC_OPS, 1, [Enable if you have libatomic-ops-dev installed])
227     fi
229     if test "x$drm_cv_atomic_primitives" = "xnone"; then
230            if test "x$INTEL" != "xauto"; then
231                    if test "x$INTEL" != "xno"; then
232                         AC_MSG_ERROR([libdrm_intel depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package, or, failing both of those, disable support for Intel GPUs by passing --disable-intel to ./configure])
233                    fi
234            else
235                    AC_MSG_WARN([Disabling libdrm_intel. It depends on atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package.])
236                    INTEL=no
237            fi
238            if test "x$RADEON" != "xauto"; then
239                    if test "x$RADEON" != "xno"; then
240                         AC_MSG_ERROR([libdrm_radeon depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package, or, failing both of those, disable support for Radeon support by passing --disable-radeon to ./configure])
241                    fi
242            else
243                    AC_MSG_WARN([Disabling libdrm_radeon. It depends on atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package.])
244                    RADEON=no
245            fi
247     else
248            if test "x$INTEL" != "xno"; then
249                    case $host_cpu in
250                            i?86|x86_64) INTEL=yes ;;
251                            *) INTEL=no ;;
252                    esac
253            fi
254            if test "x$RADEON" != "xno"; then
255                    RADEON=yes
256            fi
257     fi
258 fi
260 if test "x$INTEL" != "xno"; then
261         PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
262 fi
263 AC_SUBST(PCIACCESS_CFLAGS)
264 AC_SUBST(PCIACCESS_LIBS)
266 PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no])
267 if test "x$have_valgrind" = "xyes"; then
268         AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings])
269 fi
271 AM_CONDITIONAL(HAVE_INTEL, [test "x$INTEL" != "xno"])
272 AM_CONDITIONAL(HAVE_RADEON, [test "x$RADEON" != "xno"])
273 if test "x$RADEON" = xyes; then
274         AC_DEFINE(HAVE_RADEON, 1, [Have radeon support])
275 fi
277 AC_ARG_WITH([kernel-source],
278             [AS_HELP_STRING([--with-kernel-source],
279               [specify path to linux kernel source])],
280             [kernel_source="$with_kernel_source"])
281 AC_SUBST(kernel_source)
283 AC_SUBST(WARN_CFLAGS)
284 AC_CONFIG_FILES([
285         Makefile
286         libkms/Makefile
287         libkms/libkms.pc
288         intel/Makefile
289         intel/libdrm_intel.pc
290         radeon/Makefile
291         radeon/libdrm_radeon.pc
292         nouveau/Makefile
293         nouveau/libdrm_nouveau.pc
294         tests/Makefile
295         tests/modeprint/Makefile
296         tests/modetest/Makefile
297         tests/kmstest/Makefile
298         tests/radeon/Makefile
299         tests/vbltest/Makefile
300         include/Makefile
301         include/drm/Makefile
302         libdrm.pc])
303 AC_OUTPUT
305 echo ""
306 echo "$PACKAGE_STRING will be compiled with:"
307 echo ""
308 echo "  libkms         $LIBKMS"
309 echo "  Intel API      $INTEL"
310 echo "  vmwgfx API     $VMWGFX"
311 echo "  Radeon API     $RADEON"
312 echo "  Nouveau API    $NOUVEAU"
313 echo ""