configure.ac revision 42542f5f
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.916],
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([--disable-dri3],
343			     [Disable DRI3 support [[default=yes]]]),
344	      [DRI3=$enableval],
345	      [DRI3=yes])
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
427AC_ARG_ENABLE(glamor,
428	      AS_HELP_STRING([--enable-glamor],
429			     [Enable glamor, a new GL-based acceleration [default=no]]),
430	      [GLAMOR="$enableval"],
431	      [GLAMOR="no"])
432if test "x$GLAMOR" != "xno"; then
433	if test "x$UXA" != "xyes"; then
434		AC_MSG_ERROR([Glamor acceleration requested but UXA is not enabled])
435	fi
436	if pkg-config --exists "xorg-server >= 1.15.99.901"; then
437		GLAMOR="yes (using Xorg glamor module)"
438	else
439		PKG_CHECK_MODULES(LIBGLAMOR, [glamor >= 0.6.0])
440		PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl])
441		GLAMOR="yes (using libglamor)"
442	fi
443	AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
444fi
445
446PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_server_version xproto fontsproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES])
447ABI_VERSION=`$PKG_CONFIG --variable=abi_videodrv xorg-server`
448
449if test "x$ONLY_UMS" = "xyes"; then
450	UMS="yes"
451	KMS="no"
452fi
453
454if test "x$ONLY_KMS" = "xyes"; then
455	UMS="no"
456	KMS="yes"
457fi
458
459save_CPPFLAGS=$CPPFLAGS
460CPPFLAGS=$XORG_CFLAGS
461AC_CHECK_HEADERS([vgaHW.h], legacy="yes", legacy="no")
462CPPFLAGS=$save_CPPFLAGS
463if test "x$UMS" = "xauto"; then
464	UMS="$legacy"
465fi
466if test "x$UMS" = "xyes" -a "x$legacy" = "xno"; then
467	AC_MSG_ERROR([vgaHW support required for UMS (i810) driver])
468fi
469
470if test "x$UMS" = "xyes"; then
471	AC_ARG_ENABLE(xaa,
472		      AS_HELP_STRING([--enable-xaa],
473				     [Enable legacy X Acceleration Architecture (XAA) for i810 chipsets [default=auto]]),
474		      [XAA="$enableval"],
475		      [XAA="auto"])
476	if test "x$XAA" != "xno"; then
477		save_CPPFLAGS=$CPPFLAGS
478		CPPFLAGS=$XORG_CFLAGS
479		AC_CHECK_HEADERS([xaa.h], XAA="yes", XAA="no")
480		CPPFLAGS=$save_CPPFLAGS
481	fi
482	AC_MSG_CHECKING([whether to include XAA support])
483	AC_MSG_RESULT([$XAA])
484
485	AC_ARG_ENABLE(dga,
486		      AS_HELP_STRING([--enable-dga],
487				     [Enable legacy Direct Graphics Access (DGA) for i810 chipsets [default=auto]]),
488		      [DGA="$enableval"],
489		      [DGA="auto"])
490	if test "x$DGA" != "xno"; then
491		save_CFLAGS=$CFLAGS
492		CFLAGS=$XORG_CFLAGS
493		AC_CHECK_HEADERS([dgaproc.h], DGA="yes", DGA="no", [#include <dixstruct.h>])
494		CFLAGS=$save_CFLAGS
495	fi
496	AC_MSG_CHECKING([whether to include DGA support])
497	AC_MSG_RESULT([$DGA])
498fi
499AM_CONDITIONAL(DGA, test "x$DGA" = "xyes")
500AM_CONDITIONAL(XAA, test "x$XAA" = "xyes")
501
502AM_CONDITIONAL(KMS, test "x$KMS" = "xyes")
503if test "x$KMS" = "xyes"; then
504	AC_DEFINE(KMS,1,[Assume KMS support])
505fi
506AM_CONDITIONAL(UMS, test "x$UMS" = "xyes")
507if test "x$UMS" = "xyes"; then
508	AC_DEFINE(UMS,1,[Assume UMS support])
509fi
510
511have_dri1=no
512XORG_DRIVER_CHECK_EXT(XF86DRI, xf86driproto)
513if test "x$_EXT_CHECK" != "xno" -a "x$DRI" != "xno" -a "x$DRI1" != "xno" -a "x$UMS" = "xyes"; then
514	PKG_CHECK_MODULES(DRI1, [xf86driproto], [have_dri1=$DRI], [have_dri1=no])
515        save_CFLAGS="$CFLAGS"
516        save_CPPFLAGS="$CPPFLAGS"
517        CFLAGS="$CFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
518        CPPFLAGS="$CPPFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
519        AC_CHECK_HEADERS([dri.h sarea.h dristruct.h], [], [have_dri1=no],
520                [/* for dri.h */
521                 #include <xf86str.h>
522                 /* for dristruct.h */
523                 #include <xorg-server.h>
524                 #ifdef HAVE_DRI_H
525                 # include <dri.h>
526                 #endif
527                 #ifdef HAVE_SAREA_H
528                 # include <sarea.h>
529                 #endif
530                ])
531        CFLAGS="$save_CFLAGS"
532        CPPFLAGS="$save_CPPFLAGS"
533fi
534
535AC_MSG_CHECKING([whether to include DRI1 support])
536AC_MSG_RESULT([$have_dri1])
537
538AM_CONDITIONAL(DRI1, test "x$have_dri1" != "xno")
539if test "x$have_dri1" != "xno"; then
540        AC_DEFINE(HAVE_DRI1,1,[Enable DRI1 driver support])
541	dri_msg="$dri_msg DRI1"
542else
543        DRI1_CFLAGS=""
544        DRI1_LIBS=""
545
546        if test "x$DRI" = "xyes" -a "x$UMS" = "xyes" -a "x$DRI1" != "xno"; then
547                AC_MSG_ERROR([DRI1 requested but prerequisites not found])
548        fi
549fi
550
551have_dri2=no
552have_dri3=no
553if test "x$DRI" != "xno"; then
554	if test "x$DRI2" != "xno"; then
555		PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6], [have_dri2=$DRI], [have_dri2=no])
556	fi
557	if test "x$have_dri2" != "xno"; then
558		save_CFLAGS=$CFLAGS
559		CFLAGS="$XORG_CFLAGS $DRM_CFLAGS $DRI1_CFLAGS $DRI2_CFLAGS"
560		AC_CHECK_HEADERS([dri2.h], [], [have_dri2=no], [
561#include <dixstruct.h>
562#include <drm.h>
563])
564		CFLAGS=$save_CFLAGS
565	fi
566	if test "x$have_dri2" != "xno"; then
567		dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
568		if test "x$dridriverdir" = "x"; then
569			dridriverdir="$libdir/dri"
570		fi
571		AC_DEFINE_DIR(DRI_DRIVER_PATH, dridriverdir, [Default have_dri2 driver path])
572	fi
573
574	if test "x$DRI3" != "xno"; then
575		XORG_DRIVER_CHECK_EXT(DRI3, dri3proto)
576		if test "x$_EXT_CHECK" != "xno"; then
577			PKG_CHECK_MODULES(DRI3, [dri3proto], [have_dri3=$DRI], [])
578		fi
579	fi
580	if test "x$have_dri3" != "xno"; then
581		save_CFLAGS=$CFLAGS
582		CFLAGS="$XORG_CFLAGS $DRI3_CFLAGS"
583		AC_CHECK_DECL(DRI3, [], [have_dri3=no], [#include <xorg-server.h>])
584		AC_CHECK_HEADERS([misyncstr.h misyncshm.h], [], [have_dri3=no], [
585#include <xorg-server.h>
586#include <xf86str.h>
587#include <misync.h>
588])
589		CFLAGS=$save_CFLAGS
590	fi
591fi
592
593AC_MSG_CHECKING([whether to include DRI2 support])
594AM_CONDITIONAL(DRI2, test "x$have_dri2" != "xno")
595AC_MSG_RESULT([$have_dri2])
596if test "x$have_dri2" != "xno"; then
597        AC_DEFINE(HAVE_DRI2,1,[Enable DRI2 driver support])
598	dri_msg="$dri_msg DRI2"
599else
600	if test "x$DRI" = "xyes" -a "x$DRI2" != "xno" -a "x$KMS" = "xyes"; then
601		AC_MSG_ERROR([DRI2 requested but prerequisites not found])
602	fi
603
604	# UXA doesn't build without DRI2 headers, too late to fix
605	UXA=no
606fi
607
608AC_MSG_CHECKING([whether to include DRI3 support])
609AM_CONDITIONAL(DRI3, test "x$have_dri3" != "xno")
610AC_MSG_RESULT([$have_dri3])
611if test "x$have_dri3" != "xno"; then
612        AC_DEFINE(HAVE_DRI3,1,[Enable DRI3 driver support])
613	dri_msg="$dri_msg DRI3"
614else
615	if test "x$DRI" = "xyes" -a "x$DRI3" != "xno" -a "x$KMS" = "xyes"; then
616		AC_MSG_ERROR([DRI3 requested but prerequisites not found])
617	fi
618fi
619
620AC_CHECK_HEADERS([X11/extensions/dpmsconst.h])
621
622PRESENT="no"
623XORG_DRIVER_CHECK_EXT(PRESENT, presentproto)
624if test "x$_EXT_CHECK" != "xno"; then
625	PKG_CHECK_MODULES(PRESENT, [presentproto], [PRESENT="yes"], [])
626fi
627if test "x$PRESENT" != "xno"; then
628	save_CFLAGS=$CFLAGS
629	CFLAGS="$XORG_CFLAGS $PRESENT_CFLAGS"
630	AC_CHECK_HEADERS([present.h], [], [PRESENT="no"], [
631#include <xorg-server.h>
632#include <xf86str.h>
633])
634	CFLAGS=$save_CFLAGS
635fi
636AC_MSG_CHECKING([whether to include PRESENT support])
637AM_CONDITIONAL(PRESENT, test "x$PRESENT" != "xno")
638AC_MSG_RESULT([$PRESENT])
639if test "x$PRESENT" != "xno"; then
640        AC_DEFINE(HAVE_PRESENT,1,[Enable PRESENT driver support])
641	dri_msg="$dri_msg Present"
642fi
643
644AC_MSG_CHECKING([whether to include UXA support])
645AC_MSG_RESULT([$UXA])
646AM_CONDITIONAL(UXA, test "x$UXA" != "xno")
647
648AC_MSG_CHECKING([whether to include GLAMOR support])
649AC_MSG_RESULT([$GLAMOR])
650AM_CONDITIONAL(GLAMOR, test "x$GLAMOR" != "xno")
651
652AC_MSG_CHECKING([whether to include SNA support])
653AM_CONDITIONAL(SNA, test "x$SNA" != "xno")
654AC_MSG_RESULT([$SNA])
655
656if test "$XVMC" = "yes"; then
657	PKG_CHECK_MODULES(XVMCLIB, [xvmc dri2proto x11 x11-xcb xcb-dri2 xcb-aux libdrm_intel], [], [XVMC="no"])
658fi
659AC_MSG_CHECKING([whether to include XvMC support])
660AC_MSG_RESULT([$XVMC])
661AM_CONDITIONAL(XVMC, test "x$XVMC" = "xyes")
662if test "x$XVMC" = "xyes"; then
663	AC_DEFINE(ENABLE_XVMC,1,[Enable XvMC support])
664	xvmc_msg=" yes"
665else
666	xvmc_msg=" no"
667fi
668
669
670AC_ARG_WITH(default-accel,
671	    AS_HELP_STRING([--with-default-accel],
672			   [Select the default acceleration method out of glamor, none, sna, or uxa  [default is sna if enabled, otherwise uxa]]),
673			   [accel="$withval"],
674			   [accel="auto"])
675if test "x$accel" = "xyes"; then
676	AC_MSG_WARN([No default acceleration specified, choosing automatic selection])
677	accel="auto"
678fi
679
680AC_MSG_CHECKING([which acceleration method to use by default])
681if test "x$accel" = "xauto"; then
682	if test "x$SNA" != "xno"; then
683		accel="sna"
684	else
685		if test "x$UXA" != "xno"; then
686			accel="uxa"
687		fi
688	fi
689	if test "x$accel" = "xauto" -a "x$KMS" = "xyes"; then
690		AC_MSG_ERROR([No default acceleration option])
691	fi
692fi
693
694have_accel="none"
695if test "x$accel" = "xsna"; then
696	if test "x$SNA" != "xno"; then
697		AC_DEFINE(DEFAULT_ACCEL_METHOD, SNA, [Default acceleration method])
698		have_accel="yes"
699	else
700		AC_MSG_ERROR([SNA requested as default, but is not enabled])
701	fi
702fi
703
704if test "x$accel" = "xuxa"; then
705	if test "x$UXA" != "xno"; then
706		AC_DEFINE(DEFAULT_ACCEL_METHOD, UXA, [Default acceleration method])
707		have_accel="yes"
708	else
709		AC_MSG_ERROR([UXA requested as default, but is not enabled])
710	fi
711fi
712
713if test "x$accel" = "xglamor"; then
714	if test "x$GLAMOR" != "xno"; then
715		AC_DEFINE(DEFAULT_ACCEL_METHOD, GLAMOR, [Default acceleration method])
716		have_accel="yes"
717	else
718		AC_MSG_ERROR([glamor acceleration requested as default, but is not enabled])
719	fi
720fi
721
722if test "x$have_accel" = "xnone"; then
723	if test "x$KMS" = "xyes"; then
724		if test "x$SNA" != "xno" -o "x$UXA" != "xno"; then
725			AC_DEFINE(DEFAULT_ACCEL_METHOD, NOACCEL, [Default acceleration method])
726		else
727			AC_MSG_ERROR([Invalid default acceleration option])
728		fi
729	fi
730	accel="none"
731fi
732AC_MSG_RESULT($accel)
733
734xp_msg=""
735
736AC_ARG_ENABLE(tear-free,
737	      AS_HELP_STRING([--enable-tear-free],
738			     [Enable use of TearFree by default [default=no]]),
739	      [TEARFREE="$enableval"],
740	      [TEARFREE="no"])
741if test "x$TEARFREE" = "xyes"; then
742	AC_DEFINE(TEARFREE,1,[Enable "TearFree" by default])
743	xp_msg="$xp_msg TearFree"
744fi
745
746AC_ARG_ENABLE(rendernode,
747	      AS_HELP_STRING([--enable-rendernode],
748			     [Enable use of render nodes (experimental) [default=no]]),
749	      [RENDERNODE="$enableval"],
750	      [RENDERNODE="no"])
751AM_CONDITIONAL(USE_RENDERNODE, test "x$RENDERNODE" = "xyes")
752if test "x$RENDERNODE" = "xyes"; then
753	AC_DEFINE(USE_RENDERNODE,1,[Assume "rendernode" support])
754	xp_msg="$xp_msg rendernode"
755fi
756
757AC_ARG_ENABLE(create2,
758	      AS_HELP_STRING([--enable-create2],
759			     [Enable use of create2 ioctl (experimental) [default=no]]),
760	      [CREATE2="$enableval"],
761	      [CREATE2="no"])
762AM_CONDITIONAL(USE_CREATE2, test "x$CREATE2" = "xyes")
763if test "x$CREATE2" = "xyes"; then
764	AC_DEFINE(USE_CREATE2,1,[Assume "create2" support])
765	xp_msg="$xp_msg create2"
766fi
767
768AC_ARG_ENABLE(async-swap,
769	      AS_HELP_STRING([--enable-async-swap],
770			     [Enable use of asynchronous swaps (experimental) [default=no]]),
771	      [ASYNC_SWAP="$enableval"],
772	      [ASYNC_SWAP="no"])
773AM_CONDITIONAL(USE_ASYNC_SWAP, test "x$ASYNC_SWAP" = "xyes")
774if test "x$ASYNC_SWAP" = "xyes"; then
775	AC_DEFINE(USE_ASYNC_SWAP,1,[Assume asynchronous swap support])
776	xp_msg="$xp_msg async-swap"
777fi
778
779AC_ARG_ENABLE(debug,
780	      AS_HELP_STRING([--enable-debug],
781			     [Enables internal debugging [default=no]]),
782              [DEBUG="$enableval"],
783              [DEBUG="no"])
784AC_ARG_ENABLE(valgrind,
785	      AS_HELP_STRING([--enable-valgrind],
786			     [Enables valgrindified ioctls for debugging [default=no]]),
787              [VG="$enableval"],
788              [VG="no"])
789
790LIBS=""
791AC_SEARCH_LIBS(clock_gettime, rt, [CLOCK_GETTIME_LIBS=$LIBS])
792AC_SUBST(CLOCK_GETTIME_LIBS)
793
794sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
795
796AM_CONDITIONAL(DEBUG, test "x$DEBUG" != "xno")
797AM_CONDITIONAL(FULL_DEBUG, test "x$DEBUG" = "xfull")
798if test "x$DEBUG" = "xno"; then
799	AC_DEFINE(NDEBUG,1,[Disable internal debugging])
800else
801	if test "x$VG" != "xyes"; then
802		VG=auto
803	fi
804fi
805debug_msg=""
806have_valgrind="no"
807if test "x$VG" != "xno"; then
808	PKG_CHECK_MODULES(VALGRIND, [valgrind], have_valgrind="yes", have_valgrind="no")
809	AC_MSG_CHECKING([whether to include valgrind support])
810	if test "x$have_valgrind" = "xyes"; then
811		AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings])
812	else
813		if test "x$VG" = "xyes"; then
814			AC_MSG_ERROR([valgrind support requested, but valgrind-dev headers not found])
815		fi
816	fi
817	AC_MSG_RESULT([$have_valgrind ($VG)])
818fi
819AM_CONDITIONAL(VALGRIND, test "x$have_valgrind" = "xyes")
820if test "x$have_valgrind" = "xyes"; then
821	debug_msg="$debug_msg valgrind"
822fi
823if test "x$DEBUG" = "xsync"; then
824	AC_DEFINE(DEBUG_SYNC,1,[Enable synchronous rendering for debugging])
825	debug_msg="$debug_msg sync"
826fi
827if test "x$DEBUG" = "xmemory"; then
828	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
829	debug_msg="$debug_msg memory"
830fi
831if test "x$DEBUG" = "xpixmap"; then
832	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
833	debug_msg="$debug_msg pixmaps"
834fi
835if test "x$DEBUG" = "xfull"; then
836	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
837	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
838	AC_DEFINE(HAS_DEBUG_FULL,1,[Enable all debugging])
839        CFLAGS="$CFLAGS -O0 -ggdb3"
840	debug_msg=" full"
841fi
842if test "x$debug_msg" = "x"; then
843	debug_msg=" none"
844fi
845
846AC_CONFIG_LIBOBJ_DIR(libobj)
847AC_REPLACE_FUNCS(getline)
848
849DRIVER_NAME="intel"
850AC_SUBST([DRIVER_NAME])
851AC_SUBST([moduledir])
852AC_DEFINE_DIR([PREFIX_PATH], prefix, [installation prefix])
853AC_DEFINE_DIR([LIBEXEC_PATH], libexecdir, [libexec directory])
854
855AC_CONFIG_FILES([
856                Makefile
857                man/Makefile
858		libobj/Makefile
859                src/Makefile
860                src/legacy/Makefile
861                src/legacy/i810/Makefile
862                src/legacy/i810/xvmc/Makefile
863                src/render_program/Makefile
864                src/sna/Makefile
865                src/sna/brw/Makefile
866                src/sna/fb/Makefile
867                src/uxa/Makefile
868                xvmc/Makefile
869                xvmc/shader/Makefile
870                xvmc/shader/mc/Makefile
871                xvmc/shader/vld/Makefile
872		test/Makefile
873		tools/Makefile
874		tools/org.x.xf86-video-intel.backlight-helper.policy
875])
876AC_OUTPUT
877
878echo ""
879echo ""
880test -e `pwd $0`/README && cat `pwd $0`/README
881
882accel_msg=""
883if test "x$SNA" != "xno"; then
884	if test "$accel" = "none"; then
885		accel_msg="$accel_msg *none"
886	else
887		accel_msg="$accel_msg none"
888	fi
889	if test "$accel" = "sna"; then
890		accel_msg="$accel_msg *sna"
891	else
892		accel_msg="$accel_msg sna"
893	fi
894fi
895if test "x$UXA" != "xno"; then
896	if test "x$SNA" = "xno"; then
897		if test "$accel" = "none"; then
898			accel_msg="$accel_msg *none"
899		else
900			accel_msg="$accel_msg none"
901		fi
902	fi
903	if test "$accel" = "uxa"; then
904		accel_msg="$accel_msg *uxa"
905	else
906		accel_msg="$accel_msg uxa"
907	fi
908fi
909if test "x$GLAMOR" != "xno"; then
910	if test "$accel" = "glamor"; then
911		accel_msg="$accel_msg *glamor"
912	else
913		accel_msg="$accel_msg glamor"
914	fi
915fi
916
917if test "x$dri_msg" = "x"; then
918	dri_msg=" none"
919fi
920
921if test "x$tools_msg" = "x"; then
922	tools_msg=" none"
923fi
924
925echo ""
926echo "AC_PACKAGE_STRING will be compiled with:"
927echo "  Xorg Video ABI version: $ABI_VERSION"
928echo "  Acceleration backends:$accel_msg"
929echo "  Additional debugging support?$debug_msg"
930echo "  Support for Kernel Mode Setting? $KMS"
931echo "  Support for legacy User Mode Setting (for i810)? $UMS"
932echo "  Support for Direct Rendering Infrastructure:$dri_msg"
933echo "  Support for Xv motion compensation (XvMC and libXvMC):$xvmc_msg"
934echo "  Build additional tools and utilities?$tools_msg"
935if test -n "$xp_msg"; then
936echo "  Experimental support:$xp_msg"
937fi
938echo ""
939