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.
20#
21# Process this file with autoconf to produce a configure script
22
23# Initialize Autoconf
24AC_PREREQ([2.60])
25AC_INIT([xf86-video-intel],
26        [2.99.917],
27        [https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/issues/new],
28        [xf86-video-intel])
29AC_CONFIG_SRCDIR([Makefile.am])
30AC_CONFIG_HEADERS([config.h])
31AC_CONFIG_MACRO_DIR([m4])
32AC_CONFIG_AUX_DIR(.)
33
34# Initialize Automake
35AM_INIT_AUTOMAKE([foreign dist-bzip2])
36
37# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
38m4_ifndef([XORG_MACROS_VERSION],
39          [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen.
40  Hint: either install from source, git://anongit.freedesktop.org/xorg/util/macros or,
41  depending on you distribution, try package 'xutils-dev' or 'xorg-x11-util-macros'])])
42
43XORG_MACROS_VERSION(1.8)
44XORG_DEFAULT_OPTIONS
45
46# And disable a few very noisy warnings
47m4_ifdef([XORG_TESTSET_CFLAG], [
48XORG_TESTSET_CFLAG([NOWARNFLAGS], [-Wno-cast-qual])
49XORG_TESTSET_CFLAG([NOWARNFLAGS], [-Wno-redundant-decls])
50XORG_TESTSET_CFLAG([NOWARNFLAGS], [-Wno-maybe-uninitialized])
51])
52AC_SUBST(NOWARNFLAGS)
53
54# Require X.Org server macros (i.e. XORG_DRIVER_CHECK_EXT) to check for required modules
55m4_ifndef([XORG_DRIVER_CHECK_EXT],
56          [m4_fatal([must install xorg-server macros before running autoconf/autogen.
57  Hint: either install from source, git://anongit.freedesktop.org/xorg/xserver or,
58  depending on your distribution, try package 'xserver-xorg-dev' or 'xorg-x11-server-devel'])])
59
60# Initialize libtool
61AC_DISABLE_STATIC
62AC_PROG_LIBTOOL
63AC_SYS_LARGEFILE
64
65# Check for common libc routines redefined by os.h
66AC_CHECK_FUNCS([strlcpy strlcat strndup], [], [])
67
68# Platform specific settings
69case $host_os in
70  *linux*)
71    backlight_helper=yes
72    ;;
73esac
74
75AC_ARG_ENABLE(backlight,
76              AS_HELP_STRING([--disable-backlight],
77			     [Enable control over the backlight [default=yes]]),
78              [backlight="$enableval"],
79              [backlight="yes"])
80if test "x$backlight" = "xyes"; then
81	AC_DEFINE(USE_BACKLIGHT, 1, [Enable control of the backlight])
82fi
83
84AC_ARG_ENABLE(backlight-helper,
85              AS_HELP_STRING([--disable-backlight-helper],
86			     [Enable building the backlight helper executable for running X under a normal user [default=auto]]),
87              [backlight_helper="$enableval"],)
88AM_CONDITIONAL(BUILD_BACKLIGHT_HELPER, [test "x$backlight" = "xyes" -a "x$backlight_helper" = "xyes"])
89if test "x$backlight_helper" = "xyes"; then
90	tools_msg="$tools_msg xf86-video-intel-backlight-helper"
91	AC_DEFINE(USE_BACKLIGHT_HELPER, 1, [Enable use of the backlight helper interfaces])
92fi
93
94# Are we in a git checkout?
95dot_git=no
96if test -e .git; then
97	AC_DEFINE(HAVE_DOT_GIT, 1, [Are we in a git checkout?])
98	dot_git=yes
99fi
100AM_CONDITIONAL(HAVE_DOT_GIT, test "x$dot_git" = "xyes")
101
102# If so, we include the git description in our logs for sanity checking.
103#
104# However, for people not running their own drivers this is just noise.
105# So we copy the xserver's builderstring idiom to allow for this to be
106# overridden and perhaps replaced with something more useful.
107AC_ARG_WITH(builderstring,
108	    AS_HELP_STRING([--with-builderstring=BUILDERSTRING],
109			   [Additional builder string (default: use git describe)]),
110	    [BUILDERSTRING="$withval"],
111	    [BUILDERSTRING="x-magic-git-describe"])
112
113if test "x$BUILDERSTRING" = "xx-magic-git-describe" -a "x$dot_git" = "xyes"; then
114	AC_DEFINE(USE_GIT_DESCRIBE, 1, [Use automagic builder description])
115else
116  if test "x$BUILDERSTRING" != x -a "x$BUILDERSTRING" != "xno" -a "x$BUILDERSTRING" != xx-magic-git-describe; then
117	  AC_DEFINE_UNQUOTED(BUILDER_DESCRIPTION, ["$BUILDERSTRING"], [Builder description])
118  fi
119fi
120
121AC_ARG_ENABLE(gen4asm,
122              AS_HELP_STRING([--enable-gen4asm],
123			     [Enable rebuilding the gen4 assembly files [default=no]]),
124              [ASM="$enableval"],
125              [ASM="no"])
126
127gen4asm=no
128if test "x$ASM" != "xno"; then
129	AC_ARG_WITH(gen4asm,
130		    AS_HELP_STRING([--with-gen4asm=PATH],
131				   [Path to intel-gen4asm binary]),
132		    [path="$withval"],
133		    [path=""])
134	if test -n "$path" ; then
135		gen4asm=yes
136	else
137		PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.2], [gen4asm=yes], [gen4asm=no])
138		if test "x$ASM" = "xyes" -a "x$gen4asm" != "xyes"; then
139			AC_MSG_ERROR([intel-gen4asm support requested but not found])
140		fi
141	fi
142	if test "x$gen4asm" = "xyes"; then
143		AC_MSG_CHECKING([path to use for intel-gen4asm])
144		if test -n "$path" ; then
145			INTEL_GEN4ASM="$path"
146		else
147			INTEL_GEN4ASM="`pkg-config intel-gen4asm --variable=exec_prefix`/bin/intel-gen4asm"
148		fi
149		if ! test -e "$INTEL_GEN4ASM"; then
150			AC_MSG_ERROR([intel-gen4asm enabled, but not found. Tried '$INTEL_GEN4ASM'.])
151		fi
152		AC_MSG_RESULT([$INTEL_GEN4ASM])
153		AC_SUBST([INTEL_GEN4ASM])
154	fi
155fi
156AM_CONDITIONAL(HAVE_GEN4ASM, test "x$gen4asm" = "xyes")
157
158# Check for atomic intrinsics
159AC_CACHE_CHECK([for native atomic primitives], intel_cv_atomic_primitives,
160[
161    intel_cv_atomic_primitives="none"
162
163    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
164int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }
165int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i, j, k); }
166				    ]],[[]])],
167		   [intel_cv_atomic_primitives="Intel"],[])
168
169    if test "x$intel_cv_atomic_primitives" = "xnone"; then
170	    AC_CHECK_HEADER([atomic_ops.h], intel_cv_atomic_primitives="libatomic-ops")
171    fi
172
173    # atomic functions defined in <atomic.h> & libc on Solaris
174    if test "x$intel_cv_atomic_primitives" = "xnone"; then
175	    AC_CHECK_FUNC([atomic_cas_uint],
176			  intel_cv_atomic_primitives="Solaris")
177    fi
178
179])
180if test "x$intel_cv_atomic_primitives" = "xIntel"; then
181    AC_DEFINE(HAVE_ATOMIC_PRIMITIVES, 1,
182	      [Enable if your compiler supports the Intel __sync_* atomic primitives])
183fi
184if test "x$intel_cv_atomic_primitives" = "xlibatomic-ops"; then
185    AC_DEFINE(HAVE_LIB_ATOMIC_OPS, 1, [Enable if you have libatomic-ops-dev installed])
186fi
187
188if test "x$intel_cv_atomic_primitives" = "xnone"; then
189		AC_MSG_ERROR([xf86-video-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.])
190fi
191
192AC_ARG_ENABLE(udev,
193              AS_HELP_STRING([--disable-udev],
194                             [Disable udev-based monitor hotplug detection [default=auto]]),
195              [UDEV="$enableval"],
196              [UDEV=auto])
197
198udev_msg=" disabled"
199if test "x$UDEV" != "xno"; then
200	PKG_CHECK_MODULES(UDEV, [libudev], [udev="yes"], [udev="no"])
201	AC_CHECK_HEADERS([sys/stat.h], [], [udev="no"])
202	if test "x$UDEV" = "xyes" -a "x$udev" != "xyes"; then
203		AC_MSG_ERROR([udev support requested but not found (libudev)])
204	fi
205	if test "x$udev" = "xyes"; then
206		AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection])
207		udev_msg=" yes"
208	else
209		udev_msg=" no"
210	fi
211fi
212
213PKG_CHECK_MODULES(X11, [x11 x11-xcb xcb-dri2 xcomposite xdamage xrender xrandr xext xfixes cairo cairo-xlib-xrender pixman-1 libpng], [x11="yes"], [x11="no"])
214AM_CONDITIONAL(HAVE_X11, test "x$x11" = "xyes")
215echo X11_CLFAGS="$X11_CLFAGS" X11_LIBS="$X11_LIBS"
216
217cpuid="yes"
218AC_TRY_LINK([
219	#include <cpuid.h>
220	#include <stddef.h>
221	],
222	[
223	int eax, ebx, ecx, edx;
224	if (__get_cpuid_max(0, NULL) < 4)
225		return 0;
226	__cpuid_count(4, 0, eax, ebx, ecx, edx);
227	],
228	[cpuid="yes"],
229	[cpuid="no"]
230)
231if test "x$cpuid" = "xyes"; then
232	AC_DEFINE(HAVE_CPUID_H,1,[Found a useable cpuid.h])
233fi
234
235shm=yes
236AC_CHECK_HEADERS([sys/ipc.h sys/ipc.h], [], [shm="no"])
237AC_CHECK_HEADERS([X11/extensions/XShm.h], [], [shm="no"], [
238#include <X11/Xlibint.h>
239#include <X11/Xproto.h>
240])
241AC_CHECK_HEADERS([X11/extensions/shmproto.h X11/extensions/shmstr.h], [], [], [
242#include <X11/Xlibint.h>
243#include <X11/Xproto.h>
244])
245if test "x$ac_cv_header_X11_extensions_shmproto_h" != "xyes" -a "x$ac_cv_header_X11_extensions_shmstr_h" != "xyes"; then
246	shm="no"
247fi
248
249if test "x$shm" = "xyes"; then
250	AC_DEFINE([HAVE_MIT_SHM], 1, [Define to 1 if MIT-SHM is available])
251fi
252
253PKG_CHECK_MODULES(X11_DRI3, [xcb-dri3 xcb-sync xcb-xfixes xcb-present x11-xcb xshmfence x11 xcomposite xdamage xrender xrandr xxf86vm xext libdrm], [x11_dri3="yes"], [x11_dri3="no"])
254AM_CONDITIONAL(X11_DRI3, test "x$x11_dri3" = "xyes" -a "x$shm" = "xyes")
255AM_CONDITIONAL(X11_SHM, test "x$shm" = "xyes")
256
257PKG_CHECK_MODULES(X11_VM, [xxf86vm], [x11_vm="yes"], [x11_vm="no"])
258AM_CONDITIONAL(X11_VM, test "x$x11_vm" = "xyes")
259
260AC_ARG_ENABLE(tools,
261              AS_HELP_STRING([--disable-tools],
262			     [Enable building and installing the miscellaneous tools [default=auto]]),
263              [tools="$enableval"], [tools="auto"])
264if test "x$shm" != "xyes"; then
265	if test "x$tools" = "xyes"; then
266		AC_MSG_ERROR([Incomplete requirements for extra tools, X11 MIT-SHM extension required])
267	fi
268	tools="no"
269fi
270if test "x$tools" != "xno"; then
271	ivo_requires="xrandr xdamage xfixes xcursor xtst xrender xscrnsaver xext x11 pixman-1"
272	extra_cflags=""
273
274	ignore="xinerama"
275	PKG_CHECK_MODULES(IVO_EXTRA, [$ignore],
276			  [AC_CHECK_HEADERS([X11/extensions/Xinerama.h], [ivo_requires="$ignore $ivo_requires"], [],
277					    [#include <X11/Xlibint.h>
278					     #include <X11/Xproto.h>
279					    ])], [ignore=""])
280
281	ignore="xcb-dri3 xcb-sync x11-xcb xshmfence x11"
282	PKG_CHECK_MODULES(IVO_EXTRA, [$ignore], [ivo_requires="$ivo_requires $ignore"; extra_cflags="-DDRI3"], [ignore=""])
283
284	PKG_CHECK_MODULES(IVO, [$ivo_requires], [ivo="yes"], [ivo="no"])
285	AC_CHECK_HEADER([sys/timerfd.h], [], [ivo="no"])
286	if test "x$ivo" = "xno"; then
287		if test "x$tools" = "xyes"; then
288			AC_MSG_ERROR([Incomplete requirements for intel-virtual-output, requires $ivo_requires])
289		fi
290		tools="no"
291	fi
292
293	PKG_CHECK_MODULES(TOOL_CURSOR, [xfixes x11 libpng], [cursor="yes"], [ivo="no"])
294
295	IVO_CFLAGS="$IVO_CFLAGS $extra_cflags"
296fi
297if test "x$tools" != "xno"; then
298      tools_msg="$tools_msg intel-virtual-output"
299fi
300AC_MSG_CHECKING([whether to build additional tools])
301AC_MSG_RESULT([$tools])
302AM_CONDITIONAL(BUILD_TOOLS, test "x$tools" != "xno")
303AM_CONDITIONAL(BUILD_TOOL_CURSOR, test "x$cursor" = "xyes")
304
305# Define a configure option for an alternate module directory
306AC_ARG_WITH(xorg-module-dir,
307            AS_HELP_STRING([--with-xorg-module-dir=DIR],
308                           [Default xorg module directory [[default=$libdir/xorg/modules]]]),
309            [moduledir="$withval"],
310            [moduledir="$libdir/xorg/modules"])
311
312AC_ARG_ENABLE(dri,
313	      AS_HELP_STRING([--disable-dri],
314			     [Disable DRI support [[default=auto]]]),
315	      [DRI=$enableval],
316	      [DRI=auto])
317AC_ARG_ENABLE(dri1,
318	      AS_HELP_STRING([--disable-dri1],
319			     [Disable DRI1 support [[default=auto]]]),
320	      [DRI1=$enableval],
321	      [DRI1=auto])
322AC_ARG_ENABLE(dri2,
323	      AS_HELP_STRING([--disable-dri2],
324			     [Disable DRI2 support [[default=yes]]]),
325	      [DRI2=$enableval],
326	      [DRI2=yes])
327AC_ARG_ENABLE(dri3,
328	      AS_HELP_STRING([--disable-dri3],
329			     [Disable DRI3 support [[default=yes]]]),
330	      [DRI3=$enableval],
331	      [DRI3=yes])
332AC_ARG_WITH(default-dri,
333	    AS_HELP_STRING([--with-default-dri],
334			   [Select the default maximum DRI level [default 2]]),
335	      [DRI_DEFAULT=$withval],
336	      [DRI_DEFAULT=2])
337if test "x$DRI_DEFAULT" = "x0"; then
338	AC_DEFINE(DEFAULT_DRI_LEVEL, 0,[Default DRI level])
339else
340	AC_DEFINE(DEFAULT_DRI_LEVEL, ~0, [Default DRI level])
341fi
342
343AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc],
344                                  [Disable XvMC support [[default=yes]]]),
345              [XVMC="$enableval"],
346              [XVMC="yes"])
347
348AC_ARG_ENABLE(kms,
349	      AS_HELP_STRING([--enable-kms],
350			     [Assume KMS support [[default=yes]]]),
351              [KMS="$enableval"],
352              [KMS="yes"])
353AC_ARG_ENABLE(ums,
354	      AS_HELP_STRING([--enable-ums],
355			     [Assume UMS support [[default=auto]]]),
356              [UMS="$enableval"],
357              [UMS="auto"])
358
359AC_ARG_ENABLE(kms-only,
360	      AS_HELP_STRING([--enable-kms-only],
361			     [Only assume KMS support (no UMS) [[default=no]]]),
362              [ONLY_KMS="$enableval"],
363              [ONLY_KMS="no"])
364
365AC_ARG_ENABLE(ums-only,
366	      AS_HELP_STRING([--enable-ums-only],
367			     [Only assume UMS support (no KMS) [[default=no]]]),
368              [ONLY_UMS="$enableval"],
369              [ONLY_UMS="no"])
370
371required_xorg_server_version=1.6
372required_pixman_version=0.16
373
374PKG_CHECK_EXISTS([pixman-1 >= 0.24.0],
375		 AC_DEFINE([HAS_PIXMAN_TRIANGLES], 1, [Enable pixman triangle rasterisation])
376		 [])
377PKG_CHECK_EXISTS([pixman-1 >= 0.27.1],
378		 [AC_DEFINE([HAS_PIXMAN_GLYPHS], 1, [Enable pixman glyph cache])],
379		 [])
380# Store the list of server defined optional extensions in REQUIRED_MODULES
381XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
382XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
383XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
384
385# Obtain compiler/linker options for the driver dependencies
386PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.20]) # libdrm_intel is checked separately
387PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
388
389AC_ARG_ENABLE(sna,
390	      AS_HELP_STRING([--enable-sna],
391			     [Enable SandyBridge\'s New Acceleration (SNA) [default=auto]]),
392	      [SNA="$enableval"],
393	      [SNA=auto])
394
395AC_CHECK_HEADERS([dev/wscons/wsconsio.h])
396AC_FUNC_ALLOCA
397AC_HEADER_MAJOR
398
399if test "x$SNA" != "xno"; then
400	AC_DEFINE(USE_SNA, 1, [Enable SNA support])
401	AC_CHECK_HEADERS([sys/sysinfo.h], AC_CHECK_MEMBERS([struct sysinfo.totalram], [], [], [[#include <sys/sysinfo.h>]]))
402fi
403
404uxa_requires_libdrm=2.4.52
405uxa_requires_pixman=0.24.0
406
407AC_ARG_ENABLE(uxa,
408	      AS_HELP_STRING([--enable-uxa],
409			     [Enable Unified Acceleration Architecture (UXA) [default=auto]]),
410	      [UXA="$enableval"],
411	      [UXA=auto])
412if test "x$UXA" = "xauto"; then
413	PKG_CHECK_EXISTS([libdrm_intel >= $uxa_requires_libdrm pixman-1 >= $uxa_requires_pixman], [], [UXA=no])
414fi
415if test "x$UXA" != "xno"; then
416	AC_DEFINE(USE_UXA, 1, [Enable UXA support])
417	PKG_CHECK_MODULES(DRMINTEL, [libdrm_intel >= $uxa_requires_libdrm])
418	required_pixman_version=0.24
419	UXA=yes
420fi
421
422PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_server_version xproto fontsproto damageproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES])
423ABI_VERSION=`$PKG_CONFIG --variable=abi_videodrv xorg-server`
424XSERVER_VERSION=`$PKG_CONFIG --modversion xorg-server`
425PIXMAN_VERSION=`$PKG_CONFIG --modversion pixman-1`
426
427if test "x$ONLY_UMS" = "xyes"; then
428	UMS="yes"
429	KMS="no"
430fi
431
432if test "x$ONLY_KMS" = "xyes"; then
433	UMS="no"
434	KMS="yes"
435fi
436
437save_CPPFLAGS=$CPPFLAGS
438CPPFLAGS=$XORG_CFLAGS
439AC_CHECK_HEADERS([vgaHW.h], legacy="yes", legacy="no")
440CPPFLAGS=$save_CPPFLAGS
441if test "x$UMS" = "xauto"; then
442	UMS="$legacy"
443fi
444if test "x$UMS" = "xyes" -a "x$legacy" = "xno"; then
445	AC_MSG_ERROR([vgaHW support required for UMS (i810) driver])
446fi
447
448if test "x$UMS" = "xyes"; then
449	AC_ARG_ENABLE(xaa,
450		      AS_HELP_STRING([--enable-xaa],
451				     [Enable legacy X Acceleration Architecture (XAA) for i810 chipsets [default=auto]]),
452		      [XAA="$enableval"],
453		      [XAA="auto"])
454	if test "x$XAA" != "xno"; then
455		save_CPPFLAGS=$CPPFLAGS
456		CPPFLAGS=$XORG_CFLAGS
457		AC_CHECK_HEADERS([xaa.h], XAA="yes", XAA="no")
458		CPPFLAGS=$save_CPPFLAGS
459	fi
460	AC_MSG_CHECKING([whether to include XAA support])
461	AC_MSG_RESULT([$XAA])
462
463	AC_ARG_ENABLE(dga,
464		      AS_HELP_STRING([--enable-dga],
465				     [Enable legacy Direct Graphics Access (DGA) for i810 chipsets [default=auto]]),
466		      [DGA="$enableval"],
467		      [DGA="auto"])
468	if test "x$DGA" != "xno"; then
469		save_CFLAGS=$CFLAGS
470		CFLAGS=$XORG_CFLAGS
471		AC_CHECK_HEADERS([dgaproc.h], DGA="yes", DGA="no", [#include <dixstruct.h>])
472		CFLAGS=$save_CFLAGS
473	fi
474	AC_MSG_CHECKING([whether to include DGA support])
475	AC_MSG_RESULT([$DGA])
476fi
477AM_CONDITIONAL(DGA, test "x$DGA" = "xyes")
478AM_CONDITIONAL(XAA, test "x$XAA" = "xyes")
479
480AM_CONDITIONAL(KMS, test "x$KMS" = "xyes")
481if test "x$KMS" = "xyes"; then
482	AC_DEFINE(KMS,1,[Assume KMS support])
483fi
484AM_CONDITIONAL(UMS, test "x$UMS" = "xyes")
485if test "x$UMS" = "xyes"; then
486	AC_DEFINE(UMS,1,[Assume UMS support])
487fi
488
489have_dri1=no
490XORG_DRIVER_CHECK_EXT(XF86DRI, xf86driproto)
491if test "x$_EXT_CHECK" != "xno" -a "x$DRI" != "xno" -a "x$DRI1" != "xno" -a "x$UMS" = "xyes"; then
492	PKG_CHECK_MODULES(DRI1, [xf86driproto], [have_dri1=$DRI], [have_dri1=no])
493        save_CFLAGS="$CFLAGS"
494        save_CPPFLAGS="$CPPFLAGS"
495        CFLAGS="$CFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
496        CPPFLAGS="$CPPFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
497        AC_CHECK_HEADERS([dri.h sarea.h dristruct.h], [], [have_dri1=no],
498                [/* for dri.h */
499                 #include <xf86str.h>
500                 /* for dristruct.h */
501                 #include <xorg-server.h>
502                 #ifdef HAVE_DRI_H
503                 # include <dri.h>
504                 #endif
505                 #ifdef HAVE_SAREA_H
506                 # include <sarea.h>
507                 #endif
508                ])
509        CFLAGS="$save_CFLAGS"
510        CPPFLAGS="$save_CPPFLAGS"
511fi
512
513AC_MSG_CHECKING([whether to include DRI1 support])
514AC_MSG_RESULT([$have_dri1])
515
516AM_CONDITIONAL(DRI1, test "x$have_dri1" != "xno")
517if test "x$have_dri1" != "xno"; then
518        AC_DEFINE(HAVE_DRI1,1,[Enable DRI1 driver support])
519	str="DRI1"
520	if test "x$DRI_DEFAULT" = "x1"; then
521		AC_DEFINE(DEFAULT_DRI_LEVEL,1,[Default DRI level])
522		str="*$str"
523	fi
524	dri_msg="$dri_msg $str"
525else
526        DRI1_CFLAGS=""
527        DRI1_LIBS=""
528
529        if test "x$DRI" = "xyes" -a "x$UMS" = "xyes" -a "x$DRI1" != "xno"; then
530                AC_MSG_ERROR([DRI1 requested but prerequisites not found])
531        fi
532fi
533
534have_dri2=no
535have_dri3=no
536if test "x$DRI" != "xno"; then
537	if test "x$DRI2" != "xno"; then
538		PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6], [have_dri2=$DRI], [have_dri2=no])
539	fi
540	if test "x$have_dri2" != "xno"; then
541		save_CFLAGS=$CFLAGS
542		CFLAGS="$XORG_CFLAGS $DRM_CFLAGS $DRI1_CFLAGS $DRI2_CFLAGS"
543		AC_CHECK_HEADERS([dri2.h], [], [have_dri2=no], [
544#include <dixstruct.h>
545#include <drm.h>
546])
547		CFLAGS=$save_CFLAGS
548	fi
549	if test "x$have_dri2" != "xno"; then
550		dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
551		if test "x$dridriverdir" = "x"; then
552			dridriverdir="$libdir/dri"
553		fi
554		AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default have_dri2 driver path])
555	fi
556
557	if test "x$DRI3" != "xno"; then
558		XORG_DRIVER_CHECK_EXT(DRI3, dri3proto)
559		if test "x$_EXT_CHECK" != "xno"; then
560			PKG_CHECK_MODULES(DRI3, [dri3proto], [have_dri3=$DRI], [])
561		fi
562	fi
563	if test "x$have_dri3" != "xno"; then
564		save_CFLAGS=$CFLAGS
565		CFLAGS="$XORG_CFLAGS $DRI3_CFLAGS"
566		AC_CHECK_DECL(DRI3, [], [have_dri3=no], [#include <xorg-server.h>])
567		AC_CHECK_HEADERS([misyncstr.h misyncshm.h], [], [have_dri3=no], [
568#include <xorg-server.h>
569#include <xf86str.h>
570#include <misync.h>
571])
572		CFLAGS=$save_CFLAGS
573	fi
574fi
575
576AC_MSG_CHECKING([whether to include DRI2 support])
577AM_CONDITIONAL(DRI2, test "x$have_dri2" != "xno")
578AC_MSG_RESULT([$have_dri2])
579if test "x$have_dri2" != "xno"; then
580        AC_DEFINE(HAVE_DRI2,1,[Enable DRI2 driver support])
581	str="DRI2"
582	if test "x$DRI_DEFAULT" = "x2"; then
583		AC_DEFINE(DEFAULT_DRI_LEVEL,2,[Default DRI level])
584		str="*$str"
585	fi
586	dri_msg="$dri_msg $str"
587else
588	if test "x$DRI" = "xyes" -a "x$DRI2" != "xno" -a "x$KMS" = "xyes"; then
589		AC_MSG_ERROR([DRI2 requested but prerequisites not found])
590	fi
591
592	# UXA doesn't build without DRI2 headers, too late to fix
593	UXA=no
594fi
595
596AC_MSG_CHECKING([whether to include DRI3 support])
597AM_CONDITIONAL(DRI3, test "x$have_dri3" != "xno")
598AC_MSG_RESULT([$have_dri3])
599if test "x$have_dri3" != "xno"; then
600        AC_DEFINE(HAVE_DRI3,1,[Enable DRI3 driver support])
601	str="DRI3"
602	if test "x$DRI_DEFAULT" = "x3"; then
603		AC_DEFINE(DEFAULT_DRI_LEVEL,3,[Default DRI level])
604		str="*$str"
605	fi
606	dri_msg="$dri_msg $str"
607else
608	if test "x$DRI" = "xyes" -a "x$DRI3" != "xno" -a "x$KMS" = "xyes"; then
609		AC_MSG_ERROR([DRI3 requested but prerequisites not found])
610	fi
611fi
612
613AC_MSG_CHECKING([default DRI support])
614AC_MSG_RESULT([$DEFAULT_DRI_DEFAULT])
615
616AC_CHECK_HEADERS([X11/extensions/dpmsconst.h])
617
618PRESENT="no"
619XORG_DRIVER_CHECK_EXT(PRESENT, presentproto)
620if test "x$_EXT_CHECK" != "xno"; then
621	PKG_CHECK_MODULES(PRESENT, [presentproto], [PRESENT="yes"], [])
622fi
623if test "x$PRESENT" != "xno"; then
624	save_CFLAGS=$CFLAGS
625	CFLAGS="$XORG_CFLAGS $PRESENT_CFLAGS"
626	AC_CHECK_HEADERS([present.h], [], [PRESENT="no"], [
627#include <xorg-server.h>
628#include <xf86str.h>
629])
630	CFLAGS=$save_CFLAGS
631fi
632AC_MSG_CHECKING([whether to include PRESENT support])
633AM_CONDITIONAL(PRESENT, test "x$PRESENT" != "xno")
634AC_MSG_RESULT([$PRESENT])
635if test "x$PRESENT" != "xno"; then
636        AC_DEFINE(HAVE_PRESENT,1,[Enable PRESENT driver support])
637	dri_msg="$dri_msg Present"
638fi
639
640AC_MSG_CHECKING([whether to include UXA support])
641AC_MSG_RESULT([$UXA])
642AM_CONDITIONAL(UXA, test "x$UXA" != "xno")
643
644AC_MSG_CHECKING([whether to include SNA support])
645AM_CONDITIONAL(SNA, test "x$SNA" != "xno")
646AC_MSG_RESULT([$SNA])
647
648if test "$XVMC" = "yes"; then
649	PKG_CHECK_MODULES(XVMCLIB, [xvmc dri2proto x11 x11-xcb xcb-dri2 xcb-aux libdrm_intel], [], [XVMC="no"])
650fi
651AC_MSG_CHECKING([whether to include XvMC support])
652AC_MSG_RESULT([$XVMC])
653AM_CONDITIONAL(XVMC, test "x$XVMC" = "xyes")
654if test "x$XVMC" = "xyes"; then
655	AC_DEFINE(ENABLE_XVMC,1,[Enable XvMC support])
656	xvmc_msg=" yes"
657else
658	xvmc_msg=" no"
659fi
660
661
662AC_ARG_WITH(default-accel,
663	    AS_HELP_STRING([--with-default-accel],
664			   [Select the default acceleration method out of none, sna, or uxa  [default is sna if enabled, otherwise uxa]]),
665			   [accel="$withval"],
666			   [accel="auto"])
667if test "x$accel" = "xyes"; then
668	AC_MSG_WARN([No default acceleration specified, choosing automatic selection])
669	accel="auto"
670fi
671
672AC_MSG_CHECKING([which acceleration method to use by default])
673if test "x$accel" = "xauto"; then
674	if test "x$SNA" != "xno"; then
675		accel="sna"
676	else
677		if test "x$UXA" != "xno"; then
678			accel="uxa"
679		fi
680	fi
681	if test "x$accel" = "xauto" -a "x$KMS" = "xyes"; then
682		AC_MSG_ERROR([No default acceleration option])
683	fi
684fi
685
686have_accel="none"
687if test "x$accel" = "xsna"; then
688	if test "x$SNA" != "xno"; then
689		AC_DEFINE(DEFAULT_ACCEL_METHOD, SNA, [Default acceleration method])
690		have_accel="yes"
691	else
692		AC_MSG_ERROR([SNA requested as default, but is not enabled])
693	fi
694fi
695
696if test "x$accel" = "xuxa"; then
697	if test "x$UXA" != "xno"; then
698		AC_DEFINE(DEFAULT_ACCEL_METHOD, UXA, [Default acceleration method])
699		have_accel="yes"
700	else
701		AC_MSG_ERROR([UXA requested as default, but is not enabled])
702	fi
703fi
704
705if test "x$have_accel" = "xnone"; then
706	if test "x$KMS" = "xyes"; then
707		if test "x$SNA" != "xno" -o "x$UXA" != "xno"; then
708			AC_DEFINE(DEFAULT_ACCEL_METHOD, NOACCEL, [Default acceleration method])
709		else
710			AC_MSG_ERROR([Invalid default acceleration option])
711		fi
712	fi
713	accel="none"
714fi
715AC_MSG_RESULT($accel)
716
717xp_msg=""
718
719AC_ARG_ENABLE(tear-free,
720	      AS_HELP_STRING([--enable-tear-free],
721			     [Enable use of TearFree by default [default=no]]),
722	      [TEARFREE="$enableval"],
723	      [TEARFREE="no"])
724if test "x$TEARFREE" = "xyes"; then
725	AC_DEFINE(TEARFREE,1,[Enable "TearFree" by default])
726	xp_msg="$xp_msg TearFree"
727fi
728
729AC_ARG_ENABLE(create2,
730	      AS_HELP_STRING([--enable-create2],
731			     [Enable use of create2 ioctl (experimental) [default=no]]),
732	      [CREATE2="$enableval"],
733	      [CREATE2="no"])
734AM_CONDITIONAL(USE_CREATE2, test "x$CREATE2" = "xyes")
735if test "x$CREATE2" = "xyes"; then
736	AC_DEFINE(USE_CREATE2,1,[Assume "create2" support])
737	xp_msg="$xp_msg create2"
738fi
739
740AC_ARG_ENABLE(async-swap,
741	      AS_HELP_STRING([--enable-async-swap],
742			     [Enable use of asynchronous swaps (experimental) [default=no]]),
743	      [ASYNC_SWAP="$enableval"],
744	      [ASYNC_SWAP="no"])
745AM_CONDITIONAL(USE_ASYNC_SWAP, test "x$ASYNC_SWAP" = "xyes")
746if test "x$ASYNC_SWAP" = "xyes"; then
747	AC_DEFINE(USE_ASYNC_SWAP,1,[Assume asynchronous swap support])
748	xp_msg="$xp_msg async-swap"
749fi
750
751AC_ARG_ENABLE(debug,
752	      AS_HELP_STRING([--enable-debug],
753			     [Enables internal debugging [default=no]]),
754              [DEBUG="$enableval"],
755              [DEBUG="no"])
756AC_ARG_ENABLE(valgrind,
757	      AS_HELP_STRING([--enable-valgrind],
758			     [Enables valgrindified ioctls for debugging [default=no]]),
759              [VG="$enableval"],
760              [VG="no"])
761
762LIBS=""
763AC_SEARCH_LIBS(clock_gettime, rt, [CLOCK_GETTIME_LIBS=$LIBS])
764AC_SUBST(CLOCK_GETTIME_LIBS)
765
766sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
767
768AM_CONDITIONAL(DEBUG, test "x$DEBUG" != "xno")
769AM_CONDITIONAL(FULL_DEBUG, test "x$DEBUG" = "xfull")
770if test "x$DEBUG" = "xno"; then
771	AC_DEFINE(NDEBUG,1,[Disable internal debugging])
772else
773	if test "x$VG" != "xyes"; then
774		VG=auto
775	fi
776fi
777debug_msg=""
778have_valgrind="no"
779if test "x$VG" != "xno"; then
780	PKG_CHECK_MODULES(VALGRIND, [valgrind], have_valgrind="yes", have_valgrind="no")
781	AC_MSG_CHECKING([whether to include valgrind support])
782	if test "x$have_valgrind" = "xyes"; then
783		AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings])
784	else
785		if test "x$VG" = "xyes"; then
786			AC_MSG_ERROR([valgrind support requested, but valgrind-dev headers not found])
787		fi
788	fi
789	AC_MSG_RESULT([$have_valgrind ($VG)])
790fi
791AM_CONDITIONAL(VALGRIND, test "x$have_valgrind" = "xyes")
792if test "x$have_valgrind" = "xyes"; then
793	debug_msg="$debug_msg valgrind"
794fi
795if test "x$DEBUG" = "xsync"; then
796	AC_DEFINE(DEBUG_SYNC,1,[Enable synchronous rendering for debugging])
797	debug_msg="$debug_msg sync"
798fi
799if test "x$DEBUG" = "xmemory"; then
800	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
801	debug_msg="$debug_msg memory"
802fi
803if test "x$DEBUG" = "xpixmap"; then
804	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
805	debug_msg="$debug_msg pixmaps"
806fi
807if test "x$DEBUG" = "xfull"; then
808	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
809	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
810	AC_DEFINE(HAS_DEBUG_FULL,1,[Enable all debugging])
811        CFLAGS="$CFLAGS -O0 -ggdb3"
812	debug_msg=" full"
813fi
814if test "x$debug_msg" = "x"; then
815	debug_msg=" none"
816fi
817
818AC_CONFIG_LIBOBJ_DIR(libobj)
819AC_REPLACE_FUNCS(getline)
820
821DRIVER_NAME="intel"
822AC_SUBST([DRIVER_NAME])
823AC_SUBST([moduledir])
824AC_DEFINE_DIR([PREFIX_PATH], prefix, [installation prefix])
825AC_DEFINE_DIR([LIBEXEC_PATH], libexecdir, [libexec directory])
826
827AC_CONFIG_FILES([
828                Makefile
829                man/Makefile
830		libobj/Makefile
831                src/Makefile
832                src/legacy/Makefile
833                src/legacy/i810/Makefile
834                src/legacy/i810/xvmc/Makefile
835                src/render_program/Makefile
836                src/sna/Makefile
837                src/sna/brw/Makefile
838                src/sna/fb/Makefile
839                src/uxa/Makefile
840                xvmc/Makefile
841                xvmc/shader/Makefile
842                xvmc/shader/mc/Makefile
843                xvmc/shader/vld/Makefile
844		test/Makefile
845		benchmarks/Makefile
846		tools/Makefile
847		tools/org.x.xf86-video-intel.backlight-helper.policy
848])
849AC_OUTPUT
850
851echo ""
852echo ""
853cat $srcdir/README
854
855accel_msg=""
856if test "x$SNA" != "xno"; then
857	if test "$accel" = "none"; then
858		accel_msg="$accel_msg *none"
859	else
860		accel_msg="$accel_msg none"
861	fi
862	if test "$accel" = "sna"; then
863		accel_msg="$accel_msg *sna"
864	else
865		accel_msg="$accel_msg sna"
866	fi
867fi
868if test "x$UXA" != "xno"; then
869	if test "x$SNA" = "xno"; then
870		if test "$accel" = "none"; then
871			accel_msg="$accel_msg *none"
872		else
873			accel_msg="$accel_msg none"
874		fi
875	fi
876	if test "$accel" = "uxa"; then
877		accel_msg="$accel_msg *uxa"
878	else
879		accel_msg="$accel_msg uxa"
880	fi
881fi
882
883if test "x$dri_msg" = "x"; then
884	dri_msg=" none"
885fi
886
887if test "x$tools_msg" = "x"; then
888	tools_msg=" none"
889fi
890
891echo ""
892echo "AC_PACKAGE_STRING will be compiled with:"
893echo "  Xorg Video ABI version: $ABI_VERSION (xorg-server-$XSERVER_VERSION)"
894echo "  pixman version: pixman-1-$PIXMAN_VERSION"
895echo "  Acceleration backends:$accel_msg"
896echo "  Additional debugging support?$debug_msg"
897echo "  Support for Kernel Mode Setting? $KMS"
898echo "  Support for legacy User Mode Setting (for i810)? $UMS"
899echo "  Support for Direct Rendering Infrastructure:$dri_msg"
900echo "  Support for Xv motion compensation (XvMC and libXvMC):$xvmc_msg"
901echo "  Support for display hotplug notifications (udev):$udev_msg"
902echo "  Build additional tools and utilities?$tools_msg"
903if test -n "$xp_msg"; then
904echo "  Experimental support:$xp_msg"
905fi
906echo ""
907