configure.ac revision 42a55b46
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-r128],
26        [6.9.1],
27        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
28        [xf86-video-r128])
29AC_CONFIG_SRCDIR([Makefile.am])
30AC_CONFIG_HEADERS([config.h])
31AC_CONFIG_AUX_DIR(.)
32
33# Initialize Automake
34AM_INIT_AUTOMAKE([foreign dist-bzip2])
35
36# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
37m4_ifndef([XORG_MACROS_VERSION],
38          [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
39XORG_MACROS_VERSION(1.8)
40XORG_DEFAULT_OPTIONS
41
42AM_MAINTAINER_MODE
43
44# Initialize libtool
45AC_DISABLE_STATIC
46AC_PROG_LIBTOOL
47
48if test "x$GCC" = "xyes"; then
49	CPPFLAGS="$CPPFLAGS -Wall"
50fi
51
52AH_TOP([#include "xorg-server.h"])
53
54# Define a configure option for an alternate module directory
55AC_ARG_WITH(xorg-module-dir,
56            AS_HELP_STRING([--with-xorg-module-dir=DIR],
57                           [Default xorg module directory [[default=$libdir/xorg/modules]]]),
58            [moduledir="$withval"],
59            [moduledir="$libdir/xorg/modules"])
60
61AC_ARG_ENABLE(dri, AS_HELP_STRING([--disable-dri],
62                                  [Disable DRI support [[default=auto]]]),
63              [DRI="$enableval"],
64              [DRI=auto])
65
66AC_ARG_ENABLE(exa, AS_HELP_STRING([--disable-exa],
67				  [Disable EXA support [[default=enabled]]]),
68              [EXA="$enableval"],
69              [EXA=yes])
70
71# Store the list of server defined optional extensions in REQUIRED_MODULES
72XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
73XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
74XORG_DRIVER_CHECK_EXT(XV, videoproto)
75XORG_DRIVER_CHECK_EXT(XF86MISC, xf86miscproto)
76XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
77
78# Obtain compiler/linker options for the driver dependencies
79PKG_CHECK_MODULES(XORG, [xorg-server >= 1.2 xproto fontsproto $REQUIRED_MODULES])
80PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
81                  HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
82                  HAVE_XEXTPROTO_71="no")
83AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test "$HAVE_XEXTPROTO_71" = "yes" ])
84sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
85
86# Checks for libraries.
87
88if test "$DRI" != no; then
89	AC_CHECK_FILE([${sdkdir}/dri.h],
90                      [have_dri_h="yes"], [have_dri_h="no"])
91	AC_CHECK_FILE([${sdkdir}/sarea.h],
92                      [have_sarea_h="yes"], [have_sarea_h="no"])
93	AC_CHECK_FILE([${sdkdir}/dristruct.h],
94                      [have_dristruct_h="yes"], [have_dristruct_h="no"])
95	AC_CHECK_FILE([${sdkdir}/damage.h],
96                      [have_damage_h="yes"], [have_damage_h="no"])
97fi
98
99AC_MSG_CHECKING([whether to include DRI support])
100if test x$DRI = xauto; then
101	if test "$have_dri_h" = yes -a \
102                "$have_sarea_h" = yes -a \
103                "$have_dristruct_h" = yes; then
104		DRI="yes"
105	else
106		DRI="no"
107	fi
108fi
109AC_MSG_RESULT([$DRI])
110
111AM_CONDITIONAL(DRI, test x$DRI = xyes)
112if test "$DRI" = yes; then
113	PKG_CHECK_MODULES(DRI, [libdrm >= 2.2 xf86driproto])
114        AC_DEFINE(R128DRI,1,[Enable DRI driver support])
115        AC_DEFINE(R128DRI_DEVEL,1,[Enable developmental DRI driver support])
116fi
117
118SAVE_CPPFLAGS="$CPPFLAGS"
119CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
120# Properly handle EXA.
121AC_MSG_CHECKING([whether to enable EXA support])
122if test "x$EXA" = xyes; then
123        AC_MSG_RESULT(yes)
124
125        SAVE_CPPFLAGS="$CPPFLAGS"
126        CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
127        AC_CHECK_HEADER(exa.h,
128                       [have_exa_h="yes"], [have_exa_h="no"])
129        CPPFLAGS="$SAVE_CPPFLAGS"
130else
131        AC_MSG_RESULT(no)
132fi
133
134SAVE_CPPFLAGS="$CPPFLAGS"
135CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
136if test "x$have_exa_h" = xyes; then
137        AC_MSG_CHECKING([whether EXA version is at least 2.0.0])
138        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
139#include "exa.h"
140#if EXA_VERSION_MAJOR < 2
141#error OLD EXA!
142#endif
143                          ]])],
144                          [USE_EXA=yes],
145                          [USE_EXA=no])
146        AC_MSG_RESULT($USE_EXA)
147
148        if test "x$USE_EXA" = xyes; then
149                AC_DEFINE(USE_EXA, 1, [Build support for Exa])
150        fi
151fi
152
153AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
154	      [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
155	      [#include "xorg-server.h"])
156CPPFLAGS="$SAVE_CPPFLAGS"
157
158AC_ARG_ENABLE(xaa,
159              AS_HELP_STRING([--enable-xaa],
160                             [Enable legacy X Acceleration Architecture (XAA) [default=auto]]),
161              [XAA="$enableval"],
162              [XAA=auto])
163if test "x$XAA" != xno; then
164        save_CFLAGS=$CFLAGS
165        save_CPPFLAGS=$CPPFLAGS
166        CFLAGS=$XORG_CFLAGS
167        CPPFLAGS="$XORG_CFLAGS"
168        AC_CHECK_HEADERS([xaa.h], XAA=yes, XAA=no)
169        CFLAGS=$save_CFLAGS
170        CPPFLAGS=$save_CPPFLAGS
171fi
172AC_MSG_CHECKING([whether to include XAA support])
173AM_CONDITIONAL(XAA, test "x$XAA" = xyes)
174AC_MSG_RESULT([$XAA])
175
176AM_CONDITIONAL(USE_EXA, test "x$USE_EXA" = xyes)
177
178if test "x$XSERVER_LIBPCIACCESS" = xyes; then
179    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
180    XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
181fi
182AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
183
184# Checks for headers/macros for byte swapping
185# Known variants:
186#	<byteswap.h> bswap_16, bswap_32, bswap_64  (glibc)
187#	<sys/endian.h> __swap16, __swap32, __swap64 (OpenBSD)
188#	<sys/endian.h> bswap16, bswap32, bswap64 (other BSD's)
189#	and a fallback to local macros if none of the above are found
190
191# if <byteswap.h> is found, assume it's the correct version
192AC_CHECK_HEADERS([byteswap.h])
193
194# if <sys/endian.h> is found, have to check which version
195AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], [HAVE_SYS_ENDIAN_H="no"])
196
197if test "x$HAVE_SYS_ENDIAN_H" = "xyes" ; then
198	AC_MSG_CHECKING([for __swap16 variant of <sys/endian.h> byteswapping macros])
199	AC_LINK_IFELSE([AC_LANG_PROGRAM([
200#include <sys/types.h>
201#include <sys/endian.h>
202 ], [
203int a = 1, b;
204b = __swap16(a);
205 ])
206], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no'])
207	AC_MSG_RESULT([$SYS_ENDIAN__SWAP])
208
209	AC_MSG_CHECKING([for bswap16 variant of <sys/endian.h> byteswapping macros])
210	AC_LINK_IFELSE([AC_LANG_PROGRAM([
211#include <sys/types.h>
212#include <sys/endian.h>
213 ], [
214int a = 1, b;
215b = bswap16(a);
216 ])
217], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no'])
218	AC_MSG_RESULT([$SYS_ENDIAN_BSWAP])
219
220	if test "$SYS_ENDIAN_BSWAP" = "yes" ; then
221		USE_SYS_ENDIAN_H=yes
222		BSWAP=bswap
223	else
224		if test "$SYS_ENDIAN__SWAP" = "yes" ; then
225			USE_SYS_ENDIAN_H=yes
226			BSWAP=__swap
227		else
228			USE_SYS_ENDIAN_H=no
229		fi
230	fi
231
232	if test "$USE_SYS_ENDIAN_H" = "yes" ; then
233	    AC_DEFINE([USE_SYS_ENDIAN_H], 1,
234		[Define to use byteswap macros from <sys/endian.h>])
235	    AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16,
236			[Define to 16-bit byteswap macro])
237	    AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32,
238			[Define to 32-bit byteswap macro])
239	    AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64,
240			[Define to 64-bit byteswap macro])
241	fi
242fi
243
244AC_SUBST([moduledir])
245
246DRIVER_NAME=r128
247AC_SUBST([DRIVER_NAME])
248
249AC_MSG_NOTICE(
250[Please change the Driver line in xorg.conf from "ati" to "r128" or install]
251[the ati wrapper as well:]
252[    git://anongit.freedesktop.org/git/xorg/driver/xf86-video-ati]
253)
254
255AC_CONFIG_FILES([
256                Makefile
257                src/Makefile
258                man/Makefile
259])
260AC_OUTPUT
261