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-mach64],
26        [6.9.6],
27        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
28        [xf86-video-mach64])
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
42# Initialize libtool
43AC_DISABLE_STATIC
44AC_PROG_LIBTOOL
45
46AH_TOP([#include "xorg-server.h"])
47
48# Define a configure option for an alternate module directory
49AC_ARG_WITH(xorg-module-dir,
50            AS_HELP_STRING([--with-xorg-module-dir=DIR],
51                           [Default xorg module directory [[default=$libdir/xorg/modules]]]),
52            [moduledir="$withval"],
53            [moduledir="$libdir/xorg/modules"])
54
55AC_ARG_ENABLE(dri, AS_HELP_STRING([--disable-dri],
56                                  [Disable DRI support [[default=auto]]]),
57              [DRI="$enableval"],
58              [DRI=auto])
59
60AC_ARG_ENABLE(exa,
61              AS_HELP_STRING([--disable-exa],
62                             [Disable EXA support [[default=enabled]]]),
63              [EXA="$enableval"],
64              [EXA=yes])
65
66# Store the list of server defined optional extensions in REQUIRED_MODULES
67XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
68XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
69XORG_DRIVER_CHECK_EXT(XV, videoproto)
70XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
71
72# Obtain compiler/linker options for the driver dependencies
73PKG_CHECK_MODULES(XORG, [xorg-server >= 1.4 xproto fontsproto $REQUIRED_MODULES])
74PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
75                  HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
76                  HAVE_XEXTPROTO_71="no")
77AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test "$HAVE_XEXTPROTO_71" = "yes" ])
78sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
79
80# Checks for libraries.
81
82if test "$DRI" != no; then
83	AC_CHECK_FILE([${sdkdir}/dri.h],
84                      [have_dri_h="yes"], [have_dri_h="no"])
85	AC_CHECK_FILE([${sdkdir}/sarea.h],
86                      [have_sarea_h="yes"], [have_sarea_h="no"])
87	AC_CHECK_FILE([${sdkdir}/dristruct.h],
88                      [have_dristruct_h="yes"], [have_dristruct_h="no"])
89	AC_CHECK_FILE([${sdkdir}/damage.h],
90                      [have_damage_h="yes"], [have_damage_h="no"])
91fi
92
93AC_MSG_CHECKING([whether to include DRI support])
94if test x$DRI = xauto; then
95	if test "$have_dri_h" = yes -a \
96                "$have_sarea_h" = yes -a \
97                "$have_dristruct_h" = yes; then
98		DRI="yes"
99	else
100		DRI="no"
101	fi
102fi
103AC_MSG_RESULT([$DRI])
104
105AM_CONDITIONAL(DRI, test x$DRI = xyes)
106if test "$DRI" = yes; then
107	PKG_CHECK_MODULES(DRI, [libdrm >= 2.2 xf86driproto])
108        AC_DEFINE(XF86DRI,1,[Enable DRI driver support])
109        AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
110fi
111
112# Note that this is sort of inverted from drivers/ati/Imakefile in
113# the monolith.  We test for foo, not for !foo (i.e. ATMISC_CPIO, not
114# ATIMISC_AVOID_CPIO), but the defines are negative.  So beware.  Oh yeah,
115# TV_OUT is the special case where it's a positive define, not AVOID_TV_OUT.
116
117# AVOID_CPIO: Only x86, amd64, and alpha are cool with CPIO.  It needs a
118# little-endian, undirected PIO space of at least 64kB.
119# AVOID_DGA: ???
120# ATI_TV_OUT: This only works on x86.
121
122ATIMISC_CPIO=no
123ATIMISC_DGA=yes
124ATIMISC_TV_OUT=no
125
126case $host_cpu in
127  i*86)
128    ATIMISC_TV_OUT=yes
129    ATIMISC_CPIO=yes
130    ;;
131  x86_64|amd64|alpha|ia64)
132    ATIMISC_CPIO=yes
133    ;;
134  sparc)
135    ATIMISC_DGA=no
136    ;;
137  *)
138    ;;
139esac
140
141AC_MSG_CHECKING([whether to include PIO support])
142AM_CONDITIONAL(ATIMISC_CPIO, test "x$ATIMISC_CPIO" = xyes)
143if test "x$ATIMISC_CPIO" = xyes; then
144	AC_MSG_RESULT([yes, PIO])
145else
146	AC_DEFINE(AVOID_CPIO, 1, [Avoid PIO and use MMIO for atimisc.])
147	AC_MSG_RESULT([no, MMIO])
148fi
149
150AC_MSG_CHECKING([whether to include DGA support])
151AC_MSG_RESULT([$ATIMISC_DGA])
152AM_CONDITIONAL(ATIMISC_DGA, test "x$ATIMISC_DGA" = xyes)
153if ! test "x$ATIMISC_DGA" = xyes; then
154	AC_DEFINE(AVOID_DGA, 1, [Do not build DGA support.])
155fi
156
157AC_MSG_CHECKING([whether to include TV Out support])
158AC_MSG_RESULT([$ATIMISC_TV_OUT])
159AM_CONDITIONAL(ATIMISC_TV_OUT, test "x$ATIMISC_TV_OUT" = xyes)
160if test "x$ATIMISC_TV_OUT" = xyes; then
161	AC_DEFINE(TV_OUT, 1, [Build TV-Out support for atimisc.])
162fi
163
164# Properly handle EXA.
165AC_MSG_CHECKING([whether to enable EXA support])
166if test "x$EXA" = xyes; then
167        AC_MSG_RESULT(yes)
168
169        SAVE_CPPFLAGS="$CPPFLAGS"
170        CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
171        AC_CHECK_HEADER(exa.h,
172                       [have_exa_h="yes"], [have_exa_h="no"])
173        CPPFLAGS="$SAVE_CPPFLAGS"
174else
175        AC_MSG_RESULT(no)
176fi
177
178SAVE_CPPFLAGS="$CPPFLAGS"
179CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
180if test "x$have_exa_h" = xyes; then
181        AC_MSG_CHECKING([whether EXA version is at least 2.0.0])
182        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
183#include "exa.h"
184#if EXA_VERSION_MAJOR < 2
185#error OLD EXA!
186#endif
187                          ]])],
188                          [USE_EXA=yes],
189                          [USE_EXA=no])
190        AC_MSG_RESULT($USE_EXA)
191
192        if test "x$USE_EXA" = xyes; then
193                AC_DEFINE(USE_EXA, 1, [Build support for Exa])
194        fi
195fi
196
197AC_ARG_ENABLE(xaa,
198              AS_HELP_STRING([--enable-xaa],
199                             [Enable legacy X Acceleration Architecture (XAA) [default=auto]]),
200              [XAA="$enableval"],
201              [XAA=auto])
202if test "x$XAA" != xno; then
203        save_CFLAGS=$CFLAGS
204        save_CPPFLAGS=$CPPFLAGS
205        CFLAGS=$XORG_CFLAGS
206        CPPFLAGS="$XORG_CFLAGS"
207        AC_CHECK_HEADERS([xaa.h], XAA=yes, XAA=no)
208        CFLAGS=$save_CFLAGS
209        CPPFLAGS=$save_CPPFLAGS
210fi
211AC_MSG_CHECKING([whether to include XAA support])
212AM_CONDITIONAL(XAA, test "x$XAA" = xyes)
213if test "x$XAA" = xyes; then
214        AC_DEFINE(USE_XAA, test "x$XAA" = xyes, [Build support for XAA])
215fi
216AC_MSG_RESULT([$XAA])
217
218AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
219	      [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
220	      [#include "xorg-server.h"])
221
222CPPFLAGS="$SAVE_CPPFLAGS"
223
224AM_CONDITIONAL(USE_EXA, test "x$USE_EXA" = xyes)
225
226if test "x$XSERVER_LIBPCIACCESS" = xyes; then
227    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.12.901])
228    XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
229fi
230AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
231
232AC_SUBST([moduledir])
233
234DRIVER_NAME=mach64
235AC_SUBST([DRIVER_NAME])
236
237AC_MSG_NOTICE(
238[Please change the Driver line in xorg.conf from "ati" to "mach64"]
239[ or install the ati wrapper as well:]
240[    git://anongit.freedesktop.org/git/xorg/driver/xf86-video-ati]
241)
242
243AC_CONFIG_FILES([
244                Makefile
245                src/Makefile
246                man/Makefile
247])
248AC_OUTPUT
249