configure.ac revision 428d7b3d
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://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
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
198if test "x$UDEV" != "xno"; then
199	PKG_CHECK_MODULES(UDEV, [libudev], [udev="yes"], [udev="no"])
200	if test "x$UDEV" = "xyes" -a "x$udev" != "xyes"; then
201		AC_MSG_ERROR([udev support requested but not found (libudev)])
202	fi
203	if test "x$udev" = "xyes"; then
204		AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection])
205	fi
206fi
207
208PKG_CHECK_MODULES(X11, [x11 xrender xrandr xext xfixes cairo cairo-xlib-xrender pixman-1 libpng], [x11="yes"], [x11="no"])
209AM_CONDITIONAL(HAVE_X11, test "x$x11" = "xyes")
210
211cpuid="yes"
212AC_TRY_LINK([
213	#include <cpuid.h>
214	#include <stddef.h>
215	],
216	[
217	int eax, ebx, ecx, edx;
218	if (__get_cpuid_max(0, NULL) < 4)
219		return 0;
220	__cpuid_count(4, 0, eax, ebx, ecx, edx);
221	],
222	[cpuid="yes"],
223	[cpuid="no"]
224)
225if test "x$cpuid" = "xyes"; then
226	AC_DEFINE(HAVE_CPUID_H,1,[Found a useable cpuid.h])
227fi
228
229shm=yes
230AC_CHECK_HEADERS([sys/ipc.h sys/ipc.h], [], [shm="no"])
231AC_CHECK_HEADERS([X11/extensions/XShm.h], [], [shm="no"], [
232#include <X11/Xlibint.h>
233#include <X11/Xproto.h>
234])
235AC_CHECK_HEADERS([X11/extensions/shmproto.h X11/extensions/shmstr.h], [], [], [
236#include <X11/Xlibint.h>
237#include <X11/Xproto.h>
238])
239if test "x$ac_cv_header_X11_extensions_shmproto_h" != "xyes" -a "x$ac_cv_header_X11_extensions_shmstr_h" != "xyes"; then
240	shm="no"
241fi
242
243if test "x$shm" = "xyes"; then
244	AC_MSG_CHECKING(whether shmctl IPC_RMID allows subsequent attaches)
245	AC_TRY_RUN([
246		  #include <sys/types.h>
247		  #include <sys/ipc.h>
248		  #include <sys/shm.h>
249		  int main()
250		  {
251		      char *shmaddr;
252		      int id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0600);
253		      if (id == -1) return 2;
254		      shmaddr = shmat (id, 0, 0);
255		      shmctl (id, IPC_RMID, 0);
256		      if ((char*) shmat (id, 0, 0) == (char*) -1) {
257			  shmdt (shmaddr);
258			  return 1;
259		      }
260		      shmdt (shmaddr);
261		      shmdt (shmaddr);
262		      return 0;
263		  }
264		  ],
265		  AC_DEFINE(IPC_RMID_DEFERRED_RELEASE, 1,
266			    [Define to 1 if shared memory segments are released deferred.])
267		  AC_MSG_RESULT(yes),
268		  AC_MSG_RESULT(no),
269		  AC_MSG_RESULT(assuming no))
270	AC_DEFINE([HAVE_MIT_SHM], 1, [Define to 1 if MIT-SHM is available])
271fi
272
273PKG_CHECK_MODULES(X11_DRI3, [xcb-dri3 xcb-sync xcb-present x11-xcb xshmfence x11 xrender xext libdrm], [x11_dri3="yes"], [x11_dri3="no"])
274AM_CONDITIONAL(X11_DRI3, test "x$x11_dri3" = "xyes" -a "x$shm" = "xyes")
275AM_CONDITIONAL(X11_SHM, test "x$shm" = "xyes")
276
277AC_ARG_ENABLE(tools,
278              AS_HELP_STRING([--disable-tools],
279			     [Enable building and installing the miscellaneous tools [default=auto]]),
280              [tools="$enableval"], [tools="auto"])
281if test "x$shm" != "xyes"; then
282	if test "x$tools" = "xyes"; then
283		AC_MSG_ERROR([Incomplete requirements for extra tools, X11 MIT-SHM extension required])
284	fi
285	tools="no"
286fi
287if test "x$tools" != "xno"; then
288	ivo_requires="xrandr xdamage xfixes xcursor xtst xrender xext x11 pixman-1"
289	extra_cflags=""
290
291	ignore="xinerama"
292	PKG_CHECK_MODULES(IVO_EXTRA, [$ignore],
293			  [AC_CHECK_HEADERS([X11/extensions/Xinerama.h], [ivo_requires="$ignore $ivo_requires"], [],
294					    [#include <X11/Xlibint.h>
295					     #include <X11/Xproto.h>
296					    ])], [ignore=""])
297
298	ignore="xcb-dri3 xcb-sync x11-xcb xshmfence x11"
299	PKG_CHECK_MODULES(IVO_EXTRA, [$ignore], [ivo_requires="$ivo_requires $ignore"; extra_cflags="-DDRI3"], [ignore=""])
300
301	PKG_CHECK_MODULES(IVO, [$ivo_requires], [ivo="yes"], [ivo="no"])
302	AC_CHECK_HEADER([sys/timerfd.h], [], [ivo="no"])
303	if test "x$ivo" = "xno"; then
304		if test "x$tools" = "xyes"; then
305			AC_MSG_ERROR([Incomplete requirements for intel-virtual-output, requires $ivo_requires])
306		fi
307		tools="no"
308	fi
309
310	IVO_CFLAGS="$IVO_CFLAGS $extra_cflags"
311fi
312if test "x$tools" != "xno"; then
313      tools_msg="$tools_msg intel-virtual-output"
314fi
315AC_MSG_CHECKING([whether to build additional tools])
316AC_MSG_RESULT([$tools])
317AM_CONDITIONAL(BUILD_TOOLS, test "x$tools" != "xno")
318
319# Define a configure option for an alternate module directory
320AC_ARG_WITH(xorg-module-dir,
321            AS_HELP_STRING([--with-xorg-module-dir=DIR],
322                           [Default xorg module directory [[default=$libdir/xorg/modules]]]),
323            [moduledir="$withval"],
324            [moduledir="$libdir/xorg/modules"])
325
326AC_ARG_ENABLE(dri,
327	      AS_HELP_STRING([--disable-dri],
328			     [Disable DRI support [[default=auto]]]),
329	      [DRI=$enableval],
330	      [DRI=auto])
331AC_ARG_ENABLE(dri1,
332	      AS_HELP_STRING([--disable-dri1],
333			     [Disable DRI1 support [[default=yes]]]),
334	      [DRI1=$enableval],
335	      [DRI1=yes])
336AC_ARG_ENABLE(dri2,
337	      AS_HELP_STRING([--disable-dri2],
338			     [Disable DRI2 support [[default=yes]]]),
339	      [DRI2=$enableval],
340	      [DRI2=yes])
341AC_ARG_ENABLE(dri3,
342	      AS_HELP_STRING([--enable-dri3],
343			     [Enable DRI3 support [[default=no]]]),
344	      [DRI3=$enableval],
345	      [DRI3=no])
346
347AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc],
348                                  [Disable XvMC support [[default=yes]]]),
349              [XVMC="$enableval"],
350              [XVMC="yes"])
351
352AC_ARG_ENABLE(kms,
353	      AS_HELP_STRING([--enable-kms],
354			     [Assume KMS support [[default=yes]]]),
355              [KMS="$enableval"],
356              [KMS="yes"])
357AC_ARG_ENABLE(ums,
358	      AS_HELP_STRING([--enable-ums],
359			     [Assume UMS support [[default=auto]]]),
360              [UMS="$enableval"],
361              [UMS="auto"])
362
363AC_ARG_ENABLE(kms-only,
364	      AS_HELP_STRING([--enable-kms-only],
365			     [Only assume KMS support (no UMS) [[default=no]]]),
366              [ONLY_KMS="$enableval"],
367              [ONLY_KMS="no"])
368
369AC_ARG_ENABLE(ums-only,
370	      AS_HELP_STRING([--enable-ums-only],
371			     [Only assume UMS support (no KMS) [[default=no]]]),
372              [ONLY_UMS="$enableval"],
373              [ONLY_UMS="no"])
374
375required_xorg_server_version=1.6
376required_pixman_version=0.16
377
378if pkg-config --exists 'pixman-1 >= 0.27.1'; then
379	AC_DEFINE([HAS_PIXMAN_GLYPHS], 1, [Enable pixman glyph cache])
380fi
381
382if pkg-config --exists 'pixman-1 >= 0.24.0'; then
383	AC_DEFINE([HAS_PIXMAN_TRIANGLES], 1, [Enable pixman triangle rasterisation])
384fi
385
386# Store the list of server defined optional extensions in REQUIRED_MODULES
387XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
388XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
389XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
390
391# Obtain compiler/linker options for the driver dependencies
392PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.20]) # libdrm_intel is checked separately
393PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
394
395AC_ARG_ENABLE(sna,
396	      AS_HELP_STRING([--enable-sna],
397			     [Enable SandyBridge\'s New Acceleration (SNA) [default=auto]]),
398	      [SNA="$enableval"],
399	      [SNA=auto])
400
401if test "x$SNA" != "xno"; then
402	AC_DEFINE(USE_SNA, 1, [Enable SNA support])
403	AC_CHECK_HEADERS([sys/sysinfo.h], AC_CHECK_MEMBERS([struct sysinfo.totalram], [], [], [[#include <sys/sysinfo.h>]]))
404fi
405
406uxa_requires_libdrm=2.4.52
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	if ! pkg-config --exists "libdrm_intel >= $uxa_requires_libdrm"; then
414		UXA=no
415	fi
416	if ! pkg-config --exists 'pixman-1 >= 0.24.0'; then
417		UXA=no
418	fi
419fi
420if test "x$UXA" != "xno"; then
421	AC_DEFINE(USE_UXA, 1, [Enable UXA support])
422	PKG_CHECK_MODULES(DRMINTEL, [libdrm_intel >= $uxa_requires_libdrm])
423	required_pixman_version=0.24
424	UXA=yes
425fi
426
427PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_server_version xproto fontsproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES])
428ABI_VERSION=`$PKG_CONFIG --variable=abi_videodrv xorg-server`
429
430if test "x$ONLY_UMS" = "xyes"; then
431	UMS="yes"
432	KMS="no"
433fi
434
435if test "x$ONLY_KMS" = "xyes"; then
436	UMS="no"
437	KMS="yes"
438fi
439
440save_CPPFLAGS=$CPPFLAGS
441CPPFLAGS=$XORG_CFLAGS
442AC_CHECK_HEADERS([vgaHW.h], legacy="yes", legacy="no")
443CPPFLAGS=$save_CPPFLAGS
444if test "x$UMS" = "xauto"; then
445	UMS="$legacy"
446fi
447if test "x$UMS" = "xyes" -a "x$legacy" = "xno"; then
448	AC_MSG_ERROR([vgaHW support required for UMS (i810) driver])
449fi
450
451if test "x$UMS" = "xyes"; then
452	AC_ARG_ENABLE(xaa,
453		      AS_HELP_STRING([--enable-xaa],
454				     [Enable legacy X Acceleration Architecture (XAA) for i810 chipsets [default=auto]]),
455		      [XAA="$enableval"],
456		      [XAA="auto"])
457	if test "x$XAA" != "xno"; then
458		save_CPPFLAGS=$CPPFLAGS
459		CPPFLAGS=$XORG_CFLAGS
460		AC_CHECK_HEADERS([xaa.h], XAA="yes", XAA="no")
461		CPPFLAGS=$save_CPPFLAGS
462	fi
463	AC_MSG_CHECKING([whether to include XAA support])
464	AC_MSG_RESULT([$XAA])
465
466	AC_ARG_ENABLE(dga,
467		      AS_HELP_STRING([--enable-dga],
468				     [Enable legacy Direct Graphics Access (DGA) for i810 chipsets [default=auto]]),
469		      [DGA="$enableval"],
470		      [DGA="auto"])
471	if test "x$DGA" != "xno"; then
472		save_CFLAGS=$CFLAGS
473		CFLAGS=$XORG_CFLAGS
474		AC_CHECK_HEADERS([dgaproc.h], DGA="yes", DGA="no", [#include <dixstruct.h>])
475		CFLAGS=$save_CFLAGS
476	fi
477	AC_MSG_CHECKING([whether to include DGA support])
478	AC_MSG_RESULT([$DGA])
479fi
480AM_CONDITIONAL(DGA, test "x$DGA" = "xyes")
481AM_CONDITIONAL(XAA, test "x$XAA" = "xyes")
482
483AM_CONDITIONAL(KMS, test "x$KMS" = "xyes")
484if test "x$KMS" = "xyes"; then
485	AC_DEFINE(KMS,1,[Assume KMS support])
486fi
487AM_CONDITIONAL(UMS, test "x$UMS" = "xyes")
488if test "x$UMS" = "xyes"; then
489	AC_DEFINE(UMS,1,[Assume UMS support])
490fi
491
492have_dri1=no
493XORG_DRIVER_CHECK_EXT(XF86DRI, xf86driproto)
494if test "x$_EXT_CHECK" != "xno" -a "x$DRI" != "xno" -a "x$DRI1" != "xno" -a "x$UMS" = "xyes"; then
495	PKG_CHECK_MODULES(DRI1, [xf86driproto], [have_dri1=$DRI], [have_dri1=no])
496        save_CFLAGS="$CFLAGS"
497        save_CPPFLAGS="$CPPFLAGS"
498        CFLAGS="$CFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
499        CPPFLAGS="$CPPFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
500        AC_CHECK_HEADERS([dri.h sarea.h dristruct.h], [], [have_dri1=no],
501                [/* for dri.h */
502                 #include <xf86str.h>
503                 /* for dristruct.h */
504                 #include <xorg-server.h>
505                 #ifdef HAVE_DRI_H
506                 # include <dri.h>
507                 #endif
508                 #ifdef HAVE_SAREA_H
509                 # include <sarea.h>
510                 #endif
511                ])
512        CFLAGS="$save_CFLAGS"
513        CPPFLAGS="$save_CPPFLAGS"
514fi
515
516AC_MSG_CHECKING([whether to include DRI1 support])
517AC_MSG_RESULT([$have_dri1])
518
519AM_CONDITIONAL(DRI1, test "x$have_dri1" != "xno")
520if test "x$have_dri1" != "xno"; then
521        AC_DEFINE(HAVE_DRI1,1,[Enable DRI1 driver support])
522	dri_msg="$dri_msg DRI1"
523else
524        DRI1_CFLAGS=""
525        DRI1_LIBS=""
526
527        if test "x$DRI" = "xyes" -a "x$UMS" = "xyes" -a "x$DRI1" != "xno"; then
528                AC_MSG_ERROR([DRI1 requested but prerequisites not found])
529        fi
530fi
531
532have_dri2=no
533have_dri3=no
534if test "x$DRI" != "xno"; then
535	if test "x$DRI2" != "xno"; then
536		PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6], [have_dri2=$DRI], [have_dri2=no])
537	fi
538	if test "x$have_dri2" != "xno"; then
539		save_CFLAGS=$CFLAGS
540		CFLAGS="$XORG_CFLAGS $DRM_CFLAGS $DRI1_CFLAGS $DRI2_CFLAGS"
541		AC_CHECK_HEADERS([dri2.h], [], [have_dri2=no], [
542#include <dixstruct.h>
543#include <drm.h>
544])
545		CFLAGS=$save_CFLAGS
546	fi
547	if test "x$have_dri2" != "xno"; then
548		dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
549		if test "x$dridriverdir" = "x"; then
550			dridriverdir="$libdir/dri"
551		fi
552		AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default have_dri2 driver path])
553	fi
554
555	if test "x$DRI3" != "xno"; then
556		XORG_DRIVER_CHECK_EXT(DRI3, dri3proto)
557		if test "x$_EXT_CHECK" != "xno"; then
558			PKG_CHECK_MODULES(DRI3, [dri3proto], [have_dri3=$DRI], [])
559		fi
560	fi
561	if test "x$have_dri3" != "xno"; then
562		save_CFLAGS=$CFLAGS
563		CFLAGS="$XORG_CFLAGS $DRI3_CFLAGS"
564		AC_CHECK_DECL(DRI3, [], [have_dri3=no], [#include <xorg-server.h>])
565		AC_CHECK_HEADERS([misyncstr.h misyncshm.h], [], [have_dri3=no], [
566#include <xorg-server.h>
567#include <xf86str.h>
568#include <misync.h>
569])
570		CFLAGS=$save_CFLAGS
571	fi
572fi
573
574AC_MSG_CHECKING([whether to include DRI2 support])
575AM_CONDITIONAL(DRI2, test "x$have_dri2" != "xno")
576AC_MSG_RESULT([$have_dri2])
577if test "x$have_dri2" != "xno"; then
578        AC_DEFINE(HAVE_DRI2,1,[Enable DRI2 driver support])
579	dri_msg="$dri_msg DRI2"
580else
581	if test "x$DRI" = "xyes" -a "x$DRI2" != "xno" -a "x$KMS" = "xyes"; then
582		AC_MSG_ERROR([DRI2 requested but prerequisites not found])
583	fi
584
585	# UXA doesn't build without DRI2 headers, too late to fix
586	UXA=no
587fi
588
589AC_MSG_CHECKING([whether to include DRI3 support])
590AM_CONDITIONAL(DRI3, test "x$have_dri3" != "xno")
591AC_MSG_RESULT([$have_dri3])
592if test "x$have_dri3" != "xno"; then
593        AC_DEFINE(HAVE_DRI3,1,[Enable DRI3 driver support])
594	dri_msg="$dri_msg DRI3"
595else
596	if test "x$DRI" = "xyes" -a "x$DRI3" != "xno" -a "x$KMS" = "xyes"; then
597		AC_MSG_ERROR([DRI3 requested but prerequisites not found])
598	fi
599fi
600
601AC_CHECK_HEADERS([X11/extensions/dpmsconst.h])
602
603PRESENT="no"
604XORG_DRIVER_CHECK_EXT(PRESENT, presentproto)
605if test "x$_EXT_CHECK" != "xno"; then
606	PKG_CHECK_MODULES(PRESENT, [presentproto], [PRESENT="yes"], [])
607fi
608if test "x$PRESENT" != "xno"; then
609	save_CFLAGS=$CFLAGS
610	CFLAGS="$XORG_CFLAGS $PRESENT_CFLAGS"
611	AC_CHECK_HEADERS([present.h], [], [PRESENT="no"], [
612#include <xorg-server.h>
613#include <xf86str.h>
614])
615	CFLAGS=$save_CFLAGS
616fi
617AC_MSG_CHECKING([whether to include PRESENT support])
618AM_CONDITIONAL(PRESENT, test "x$PRESENT" != "xno")
619AC_MSG_RESULT([$PRESENT])
620if test "x$PRESENT" != "xno"; then
621        AC_DEFINE(HAVE_PRESENT,1,[Enable PRESENT driver support])
622	dri_msg="$dri_msg Present"
623fi
624
625AC_MSG_CHECKING([whether to include UXA support])
626AC_MSG_RESULT([$UXA])
627AM_CONDITIONAL(UXA, test "x$UXA" != "xno")
628
629AC_MSG_CHECKING([whether to include SNA support])
630AM_CONDITIONAL(SNA, test "x$SNA" != "xno")
631AC_MSG_RESULT([$SNA])
632
633if test "$XVMC" = "yes"; then
634	PKG_CHECK_MODULES(XVMCLIB, [xvmc dri2proto x11 x11-xcb xcb-dri2 xcb-aux libdrm_intel], [], [XVMC="no"])
635fi
636AC_MSG_CHECKING([whether to include XvMC support])
637AC_MSG_RESULT([$XVMC])
638AM_CONDITIONAL(XVMC, test "x$XVMC" = "xyes")
639if test "x$XVMC" = "xyes"; then
640	AC_DEFINE(ENABLE_XVMC,1,[Enable XvMC support])
641	xvmc_msg=" yes"
642else
643	xvmc_msg=" no"
644fi
645
646
647AC_ARG_WITH(default-accel,
648	    AS_HELP_STRING([--with-default-accel],
649			   [Select the default acceleration method out of none, sna, or uxa  [default is sna if enabled, otherwise uxa]]),
650			   [accel="$withval"],
651			   [accel="auto"])
652if test "x$accel" = "xyes"; then
653	AC_MSG_WARN([No default acceleration specified, choosing automatic selection])
654	accel="auto"
655fi
656
657AC_MSG_CHECKING([which acceleration method to use by default])
658if test "x$accel" = "xauto"; then
659	if test "x$SNA" != "xno"; then
660		accel="sna"
661	else
662		if test "x$UXA" != "xno"; then
663			accel="uxa"
664		fi
665	fi
666	if test "x$accel" = "xauto" -a "x$KMS" = "xyes"; then
667		AC_MSG_ERROR([No default acceleration option])
668	fi
669fi
670
671have_accel="none"
672if test "x$accel" = "xsna"; then
673	if test "x$SNA" != "xno"; then
674		AC_DEFINE(DEFAULT_ACCEL_METHOD, SNA, [Default acceleration method])
675		have_accel="yes"
676	else
677		AC_MSG_ERROR([SNA requested as default, but is not enabled])
678	fi
679fi
680
681if test "x$accel" = "xuxa"; then
682	if test "x$UXA" != "xno"; then
683		AC_DEFINE(DEFAULT_ACCEL_METHOD, UXA, [Default acceleration method])
684		have_accel="yes"
685	else
686		AC_MSG_ERROR([UXA requested as default, but is not enabled])
687	fi
688fi
689
690if test "x$have_accel" = "xnone"; then
691	if test "x$KMS" = "xyes"; then
692		if test "x$SNA" != "xno" -o "x$UXA" != "xno"; then
693			AC_DEFINE(DEFAULT_ACCEL_METHOD, NOACCEL, [Default acceleration method])
694		else
695			AC_MSG_ERROR([Invalid default acceleration option])
696		fi
697	fi
698	accel="none"
699fi
700AC_MSG_RESULT($accel)
701
702xp_msg=""
703
704AC_ARG_ENABLE(tear-free,
705	      AS_HELP_STRING([--enable-tear-free],
706			     [Enable use of TearFree by default [default=no]]),
707	      [TEARFREE="$enableval"],
708	      [TEARFREE="no"])
709if test "x$TEARFREE" = "xyes"; then
710	AC_DEFINE(TEARFREE,1,[Enable "TearFree" by default])
711	xp_msg="$xp_msg TearFree"
712fi
713
714AC_ARG_ENABLE(rendernode,
715	      AS_HELP_STRING([--enable-rendernode],
716			     [Enable use of render nodes (experimental) [default=no]]),
717	      [RENDERNODE="$enableval"],
718	      [RENDERNODE="no"])
719AM_CONDITIONAL(USE_RENDERNODE, test "x$RENDERNODE" = "xyes")
720if test "x$RENDERNODE" = "xyes"; then
721	AC_DEFINE(USE_RENDERNODE,1,[Assume "rendernode" support])
722	xp_msg="$xp_msg rendernode"
723fi
724
725AC_ARG_ENABLE(wc-mmap,
726	      AS_HELP_STRING([--enable-wc-mmap],
727			     [Enable use of WriteCombining mmaps [default=no]]),
728	      [WC_MMAP="$enableval"],
729	      [WC_MMAP="no"])
730if test "x$WC_MMAP" = "xyes"; then
731	AC_DEFINE(USE_WC_MMAP,1,[Enable use of WriteCombining mmaps])
732	xp_msg="$xp_msg mmap(wc)"
733fi
734
735AC_ARG_ENABLE(create2,
736	      AS_HELP_STRING([--enable-create2],
737			     [Enable use of create2 ioctl (experimental) [default=no]]),
738	      [CREATE2="$enableval"],
739	      [CREATE2="no"])
740AM_CONDITIONAL(USE_CREATE2, test "x$CREATE2" = "xyes")
741if test "x$CREATE2" = "xyes"; then
742	AC_DEFINE(USE_CREATE2,1,[Assume "create2" support])
743	xp_msg="$xp_msg create2"
744fi
745
746AC_ARG_ENABLE(async-swap,
747	      AS_HELP_STRING([--enable-async-swap],
748			     [Enable use of asynchronous swaps (experimental) [default=no]]),
749	      [ASYNC_SWAP="$enableval"],
750	      [ASYNC_SWAP="no"])
751AM_CONDITIONAL(USE_ASYNC_SWAP, test "x$ASYNC_SWAP" = "xyes")
752if test "x$ASYNC_SWAP" = "xyes"; then
753	AC_DEFINE(USE_ASYNC_SWAP,1,[Assume asynchronous swap support])
754	xp_msg="$xp_msg async-swap"
755fi
756
757AC_ARG_ENABLE(debug,
758	      AS_HELP_STRING([--enable-debug],
759			     [Enables internal debugging [default=no]]),
760              [DEBUG="$enableval"],
761              [DEBUG="no"])
762AC_ARG_ENABLE(valgrind,
763	      AS_HELP_STRING([--enable-valgrind],
764			     [Enables valgrindified ioctls for debugging [default=no]]),
765              [VG="$enableval"],
766              [VG="no"])
767
768LIBS=""
769AC_SEARCH_LIBS(clock_gettime, rt, [CLOCK_GETTIME_LIBS=$LIBS])
770AC_SUBST(CLOCK_GETTIME_LIBS)
771
772sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
773
774AM_CONDITIONAL(DEBUG, test "x$DEBUG" != "xno")
775AM_CONDITIONAL(FULL_DEBUG, test "x$DEBUG" = "xfull")
776if test "x$DEBUG" = "xno"; then
777	AC_DEFINE(NDEBUG,1,[Disable internal debugging])
778else
779	if test "x$VG" != "xyes"; then
780		VG=auto
781	fi
782fi
783debug_msg=""
784have_valgrind="no"
785if test "x$VG" != "xno"; then
786	PKG_CHECK_MODULES(VALGRIND, [valgrind], have_valgrind="yes", have_valgrind="no")
787	AC_MSG_CHECKING([whether to include valgrind support])
788	if test "x$have_valgrind" = "xyes"; then
789		AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings])
790	else
791		if test "x$VG" = "xyes"; then
792			AC_MSG_ERROR([valgrind support requested, but valgrind-dev headers not found])
793		fi
794	fi
795	AC_MSG_RESULT([$have_valgrind ($VG)])
796fi
797AM_CONDITIONAL(VALGRIND, test "x$have_valgrind" = "xyes")
798if test "x$have_valgrind" = "xyes"; then
799	debug_msg="$debug_msg valgrind"
800fi
801if test "x$DEBUG" = "xsync"; then
802	AC_DEFINE(DEBUG_SYNC,1,[Enable synchronous rendering for debugging])
803	debug_msg="$debug_msg sync"
804fi
805if test "x$DEBUG" = "xmemory"; then
806	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
807	debug_msg="$debug_msg memory"
808fi
809if test "x$DEBUG" = "xpixmap"; then
810	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
811	debug_msg="$debug_msg pixmaps"
812fi
813if test "x$DEBUG" = "xfull"; then
814	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
815	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
816	AC_DEFINE(HAS_DEBUG_FULL,1,[Enable all debugging])
817        CFLAGS="$CFLAGS -O0 -ggdb3"
818	debug_msg=" full"
819fi
820if test "x$debug_msg" = "x"; then
821	debug_msg=" none"
822fi
823
824AC_CONFIG_LIBOBJ_DIR(libobj)
825AC_REPLACE_FUNCS(getline)
826
827DRIVER_NAME="intel"
828AC_SUBST([DRIVER_NAME])
829AC_SUBST([moduledir])
830AC_DEFINE_DIR([PREFIX_PATH], prefix, [installation prefix])
831AC_DEFINE_DIR([LIBEXEC_PATH], libexecdir, [libexec directory])
832
833AC_CONFIG_FILES([
834                Makefile
835                man/Makefile
836		libobj/Makefile
837                src/Makefile
838                src/legacy/Makefile
839                src/legacy/i810/Makefile
840                src/legacy/i810/xvmc/Makefile
841                src/render_program/Makefile
842                src/sna/Makefile
843                src/sna/brw/Makefile
844                src/sna/fb/Makefile
845                src/uxa/Makefile
846                xvmc/Makefile
847                xvmc/shader/Makefile
848                xvmc/shader/mc/Makefile
849                xvmc/shader/vld/Makefile
850		test/Makefile
851		tools/Makefile
852		tools/org.x.xf86-video-intel.backlight-helper.policy
853])
854AC_OUTPUT
855
856echo ""
857echo ""
858test -e `pwd $0`/README && cat `pwd $0`/README
859
860accel_msg=""
861if test "x$SNA" != "xno"; then
862	if test "$accel" = "none"; then
863		accel_msg="$accel_msg *none"
864	else
865		accel_msg="$accel_msg none"
866	fi
867	if test "$accel" = "sna"; then
868		accel_msg="$accel_msg *sna"
869	else
870		accel_msg="$accel_msg sna"
871	fi
872fi
873if test "x$UXA" != "xno"; then
874	if test "x$SNA" = "xno"; then
875		if test "$accel" = "none"; then
876			accel_msg="$accel_msg *none"
877		else
878			accel_msg="$accel_msg none"
879		fi
880	fi
881	if test "$accel" = "uxa"; then
882		accel_msg="$accel_msg *uxa"
883	else
884		accel_msg="$accel_msg uxa"
885	fi
886fi
887
888if test "x$dri_msg" = "x"; then
889	dri_msg=" none"
890fi
891
892if test "x$tools_msg" = "x"; then
893	tools_msg=" none"
894fi
895
896echo ""
897echo "AC_PACKAGE_STRING will be compiled with:"
898echo "  Xorg Video ABI version: $ABI_VERSION"
899echo "  Acceleration backends:$accel_msg"
900echo "  Additional debugging support?$debug_msg"
901echo "  Support for Kernel Mode Setting? $KMS"
902echo "  Support for legacy User Mode Setting (for i810)? $UMS"
903echo "  Support for Direct Rendering Infrastructure:$dri_msg"
904echo "  Support for Xv motion compensation (XvMC and libXvMC):$xvmc_msg"
905echo "  Build additional tools and utilities?$tools_msg"
906if test -n "$xp_msg"; then
907echo "  Experimental support:$xp_msg"
908fi
909echo ""
910