summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 55e4262f4d974368800d50399b8a12b53188bdfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# Process this file with autoconf to produce a configure script

AC_PREREQ(2.57)
AC_INIT([xf86-video-radeonhd],
        1.3.0,
        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/radeonhd],
        xf86-video-radeonhd)

AC_CONFIG_SRCDIR([Makefile.am])
AM_CONFIG_HEADER([config.h])
AC_CONFIG_AUX_DIR(.)

AM_INIT_AUTOMAKE([dist-bzip2])

AM_MAINTAINER_MODE

AC_CONFIG_FILES([shave shave-libtool])


# Program checks.
AC_DISABLE_STATIC
AC_PROG_CC

dnl Define SED var without requiring AC_PROG_SED (new in autoconf-2.59b)
m4_ifdef([AC_PROG_SED], [AC_PROG_SED], [AC_SUBST([SED], [${SED-sed}])])

AC_MSG_CHECKING([whether $SED can substitute tabs and newlines for text])
dnl One tab, a letter and two newlines
cat>sed-test.1<<EOF
	y

EOF
echo x | sed 's/x/\ty\n/' > sed-test.2
if cmp -s sed-test.1 sed-test.2; then
	AC_MSG_RESULT([yes])
else
	AC_MSG_RESULT([no])
fi
AM_CONDITIONAL([HAVE_SED_WITH_REASONABLE_SUBSTITUTION], [cmp -s sed-test.1 sed-test.2])
rm -f sed-test.1 sed-test.2

CXX=no
F77=no
AC_PROG_LIBTOOL


AH_TOP([#ifndef _CONFIG_H])
AH_TOP([# define _CONFIG_H])
AH_TOP([# include "xorg-server.h"])
AH_BOTTOM([#endif])

AC_ARG_WITH(xorg-module-dir,
            AC_HELP_STRING([--with-xorg-module-dir=DIR],
                           [Default xorg module directory (default $libdir/xorg/modules)]),
            [moduledir="$withval"],
            [moduledir="$libdir/xorg/modules"])

AC_ARG_ENABLE(exa,
              AC_HELP_STRING([--disable-exa],
	                     [Disable EXA support (default enabled)]),
              [EXA="$enableval"],
              [EXA=yes])

AC_ARG_ENABLE(dri,
              AC_HELP_STRING([--disable-dri],
	                     [Disable DRI support (default enabled)]),
              [DRI="$enableval"],
              [DRI=yes])

# Extensions checks.
m4_pattern_forbid([XORG_DRIVER_CHECK_EXT])dnl
XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
XORG_DRIVER_CHECK_EXT(XV, videoproto)
XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
# @@@@ We don't do DGA any more

# pkg-config packages checks
# @@@@ need to check for the right server version once RandR 1.2 is in.
# @@@ do we really need fontsproto here?
PKG_CHECK_MODULES(XORG, [xorg-server xproto fontsproto $REQUIRED_MODULES])
PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
                  HAVE_XEXTPROTO_71="yes"; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]),
                  HAVE_XEXTPROTO_71="no")
AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test "$HAVE_XEXTPROTO_71" = "yes" ])
sdkdir=$(pkg-config --variable=sdkdir xorg-server)


# Header files checks.
AC_HEADER_STDC

PKG_CHECK_MODULES(PCIUTILS, libpci,,
   [AC_MSG_WARN([libpci not registered in pkgconfig, will guess instead])
    test "x$PCIUTILS_CFLAGS$PCIUTILS_LIBS" = "x" && PCIUTILS_LIBS="-lpci -lz"
])

SAVED_CPPFLAGS="$CPPFLAGS"
SAVED_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PCIUTILS_CFLAGS"
CPPFLAGS="$CPPFLAGS $PCIUTILS_CFLAGS"
AC_CHECK_HEADER([pci/pci.h],
                [AC_DEFINE([HAVE_PCI_PCI_H], [1],
                           [Define to 1 if you have <pci/pci.h>.])
                 have_pci_pci_h=yes],
                [AC_MSG_WARN([Caution: Will not compile rhd_conntest without pciutils headers.])])
AM_CONDITIONAL([HAVE_PCI_PCI_H], [test "x$have_pci_pci_h" = "xyes"])

# Properly handle EXA.
CPPFLAGS="$SAVED_CPPFLAGS $XORG_CFLAGS"
CFLAGS="$SAVED_CFLAGS"

AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
              [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
              [#include "xorg-server.h"])
if test "x$XSERVER_LIBPCIACCESS" = xyes; then
	PKG_CHECK_MODULES([PCIACCESS], [pciaccess])
	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
fi
AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)

# basic exa check.
AC_MSG_CHECKING([whether to enable EXA support])
if test "x$EXA" = xyes; then
        AC_MSG_RESULT(yes)
        AC_CHECK_HEADER(exa.h,
                       [have_exa_h="yes"], [have_exa_h="no"])
else
        AC_MSG_RESULT(no)
fi

# exa version check.
if test "x$have_exa_h" = xyes; then
        AC_MSG_CHECKING([whether EXA version is at least 2.0.0])
        AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
#include "exa.h"
#if EXA_VERSION_MAJOR < 2
#error OLD EXA!
#endif
                          ]])],
                          [USE_EXA=yes],
                          [USE_EXA=no])
        AC_MSG_RESULT($USE_EXA)

        if test "x$USE_EXA" = xyes; then
                AC_DEFINE(USE_EXA, 1, [Build support for Exa])
        fi
fi

AM_CONDITIONAL(USE_EXA, test "x$USE_EXA" = xyes)

# Handle RandR1.2
AC_CHECK_HEADER(xf86RandR12.h, [have_randr12="yes"], [have_randr12="no"], [#include <xf86.h>])
if test "x$have_randr12" = xyes; then
	AC_DEFINE(RANDR_12_SUPPORT, 1, [Build RandR 1.2 Support])
fi

AC_MSG_CHECKING([whether to enable RandR1.2 support])
AC_MSG_RESULT($have_randr12)

# Handle DRI
CPPFLAGS="$SAVED_CPPFLAGS $XORG_CFLAGS"
CFLAGS="$SAVED_CFLAGS $XORG_CFLAGS"

# basic dri check.
USE_DRI=no
if test "x$DRI" = xyes; then
	USE_DRI="yes"
	AC_CHECK_DECL(XF86DRI,, [USE_DRI=no], [#include <xorg-server.h>])
	XORG_CFLAGS="$XORG_CFLAGS $DRI_CFLAGS"
	PKG_CHECK_MODULES(DRI, [libdrm >= 2.2 xf86driproto],, [USE_DRI=no])
fi

AC_MSG_CHECKING([whether to enable DRI support])
AC_MSG_RESULT($USE_DRI)
AM_CONDITIONAL(USE_DRI, test "x$USE_DRI" = xyes)

if test "x$USE_DRI" = "xyes"; then
	AC_DEFINE(USE_DRI, 1, [Build support for DRI])
	CFLAGS="$CFLAGS $DRI_CFLAGS"
	CPPFLAGS="$CPPFLAGS $DRI_CFLAGS"
	AC_CHECK_HEADER([xf86drmMode.h],
			[AC_DEFINE([HAVE_XF86DRMMODE_H], [1],
				[Define to 1 if you have xf86drmMode.h])])
fi

AC_CHECK_FILE([${sdkdir}/damage.h],
	[AC_DEFINE(DAMAGE,1,[Use Damage extension])], [])

# check for xf86_ansic.h
CFLAGS="$SAVED_CFLAGS"
CPPFLAGS="$SAVED_CPPFLAGS"

AC_CHECK_HEADER([${sdkdir}/xf86_ansic.h],
		[AC_DEFINE([HAVE_XF86_ANSIC_H], [1],
			   [Define to 1 if you have <${sdkdir}/xf86_ansic.h>.])
		have_xf86_ansic_h=yes])
AM_CONDITIONAL([HAVE_XF86_ANSIC_H], [test "x$have_xf86_ansic_h" = "xyes"])

SAVED_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $XORG_CFLAGS"

# Check whether MonRec has a reducedblanking member.
AC_CHECK_MEMBER([MonRec.reducedblanking],
         [MONREC_HAS_REDUCED=yes], [MONREC_HAS_REDUCED=no],
         [#include "${sdkdir}/xf86.h"])
if test "x$MONREC_HAS_REDUCED" = xyes; then
        AC_DEFINE(MONREC_HAS_REDUCED, 1, [MonRec has member reducedblanking])
fi

# Check whether MonRec has a maxPixClock member.
AC_CHECK_MEMBER([MonRec.maxPixClock],
         [MONREC_HAS_BANDWIDTH=yes], [MONREC_HAS_BANDWIDTH=no],
         [#include "${sdkdir}/xf86.h"])
if test "x$MONREC_HAS_BANDWIDTH" = xyes; then
        AC_DEFINE(MONREC_HAS_BANDWIDTH, 1, [MonRec has member maxPixClock])
fi

# Check whether xf86CrtcFuncsRec has a set_mode_major member.
AC_CHECK_MEMBER([xf86CrtcFuncsRec.set_mode_major],
         [XF86CRTCFUNCS_HAS_SETMODEMAJOR=yes], [XF86CRTCFUNCS_HAS_SETMODEMAJOR=no],
         [#include "${sdkdir}/xorg-server.h"
#include "${sdkdir}/xf86.h"
#include "${sdkdir}/xf86Crtc.h"])
if test "x$XF86CRTCFUNCS_HAS_SETMODEMAJOR" = xyes; then
        AC_DEFINE(XF86CRTCFUNCS_HAS_SETMODEMAJOR, 1, [xf86CrtcFuncsRec has member set_mode_major])
fi

AC_CHECK_DECL(xf86RotateFreeShadow,
              [AC_DEFINE(HAVE_FREE_SHADOW, 1, [have RotateFreeShadow API])],
              [],
              [#include <xorg-server.h>
               #include <windowstr.h>
               #include <xf86Crtc.h>])

AC_CHECK_DECL(pci_device_enable,
              [AC_DEFINE(HAVE_PCI_DEVICE_ENABLE, 1, [Have pci_device_enable prototype])],
              [],
              [#include <pciaccess.h>])

CFLAGS="$SAVED_CFLAGS"

AC_ARG_ENABLE(atombios, AC_HELP_STRING([--disable-atombios],
                                  [Disable AtomBIOS support [[default=no]]]),
              [do_atombios="$enableval"],
              [do_atombios=yes])

AC_ARG_ENABLE(atombios-parser, AC_HELP_STRING([--disable-atombios-parser],
                                  [Disable AtomBIOS parser support [[default=no]]]),
              [do_atombios_parser="$enableval"],
              [do_atombios_parser=yes])

AC_CHECK_FILE([${srcdir}/src/AtomBios/includes/atombios.h],
              [have_atombios_h="yes"], [have_atombios_h="no"])

AC_CHECK_FILE([${srcdir}/src/AtomBios/includes/Decoder.h],
              [have_atombios_parser="yes"], [have_atombios_parser="no"])

AC_MSG_CHECKING([whether to include AtomBIOS])
if test "$have_atombios_h" = yes -a \
	"$do_atombios" = yes; then
	support_atombios="yes"
        AC_DEFINE(ATOM_BIOS, 1, [Add support for AtomBIOS tables])
else
	support_atombios="no"
fi

AC_MSG_RESULT([$support_atombios])

AC_MSG_CHECKING([whether to include AtomBIOS parser])
if test "$support_atombios" = yes -a \
	"$do_atombios_parser" = yes -a \
	"$have_atombios_parser" = yes; then
	support_atombios_parser="yes"
        AC_DEFINE(ATOM_BIOS_PARSER, 1, [Add support for AtomBIOS code])
else
	support_atombios_parser="no"
fi

AC_MSG_RESULT([$support_atombios_parser])

AM_CONDITIONAL(ATOM_BIOS, test x$support_atombios = xyes)

AM_CONDITIONAL(ATOM_BIOS_PARSER, test x$support_atombios_parser = xyes)

# libraries checks.
AC_CHECK_LIB([z], [gzopen], [have_zlib=yes], [have_zlib=no])
AM_CONDITIONAL([HAVE_ZLIB], [test "x$have_zlib" = "xyes"])

# compiler flags

dnl AC_PROG_CC_FLAG(flag,action-if-found,action-if-not-found)
AC_DEFUN([AC_PROG_CC_FLAG],[
  AC_LANG_CONFTEST([AC_LANG_PROGRAM([[]])])
  AC_MSG_CHECKING([whether $CC supports $1])
  if $CC $1 -c -o /dev/null conftest.c >/dev/null 2>&1 ; then
    AC_MSG_RESULT([yes])
    $2
  else
    AC_MSG_RESULT([no])
    $3
  fi
])

# Extra Warnings
# Due to xorg/os.h: -Wno-variadic-macros
# For testing: make CFLAGS="-O2 -Wshadow -Wunreachable-code -fno-inline-functions"
WARN_CFLAGS=""
for w in \
  -Wall \
  -Wextra -Wno-unused-parameter \
  -Werror-implicit-function-declaration \
  -Wstrict-aliasing -Wstrict-overflow \
  -Wpointer-arith -Woverlength-strings -Wvolatile-register-var \
  -Winit-self -Wbad-function-cast \
  -Wstrict-prototypes -Wold-style-definition \
  -Wnested-externs -Wdisabled-optimization \
  -Wno-unknown-pragmas ;
do
  AC_PROG_CC_FLAG($w,[WARN_CFLAGS="$WARN_CFLAGS $w"],)
done

# atombios.h prohibits -std=c99 due to unnamed unions
PEDANTIC_CFLAGS=""
for w in -Wno-long-long -Wno-variadic-macros ; do
  AC_PROG_CC_FLAG($w,[PEDANTIC_CFLAGS="$PEDANTIC_CFLAGS $w"],)
done

# AtomBios special flags
ATOMBIOS_CFLAGS=""
for w in -Wno-unknown-pragmas ; do
  AC_PROG_CC_FLAG($w,[ATOMBIOS_CFLAGS="$ATOMBIOS_CFLAGS $w"],)
done

# Optimizations
case "x$CFLAGS" in
dnl Automake needs extra escaping
  [*-O[2-9]*)]
    AC_MSG_NOTICE([Doing optimized build, checking for additional options])
    for w in -finline-functions ; do
      AC_PROG_CC_FLAG($w,[CFLAGS="$CFLAGS -finline-functions"],)
    done
    ;;
esac

# Substitute

AC_SUBST([PCIUTILS_CFLAGS])
AC_SUBST([PCIUTILS_LIBS])
AC_SUBST([XORG_CFLAGS])
AC_SUBST([DRI_CFLAGS])
AC_SUBST([WARN_CFLAGS])
AC_SUBST([PEDANTIC_CFLAGS])
AC_SUBST([ATOMBIOS_CFLAGS])
AC_SUBST([RANDR_VERSION],[`pkg-config --modversion randrproto`])
AC_SUBST([moduledir])

DRIVER_NAME=radeonhd
AC_SUBST([DRIVER_NAME])

m4_pattern_forbid([XORG_MANPAGE_SECTIONS])dnl
XORG_MANPAGE_SECTIONS
m4_pattern_forbid([XORG_RELEASE_VERSION])dnl
XORG_RELEASE_VERSION

dnl These are also defined in XORG_RELEASE_VERSION since 2006-11-30.
dnl So we check whether XORG_RELEASE_VERSION has already done this
dnl for us.
if test "x$PVM$PVP" = "x"; then
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],
		[$(echo $PACKAGE_VERSION | cut -d . -f 1)],
		[Major Version])
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],
		[$(echo $PACKAGE_VERSION | cut -d . -f 2)],
		[Minor Version])
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL],
		[$(echo $PACKAGE_VERSION | cut -d . -f 3)],
		[Patchlevel Version])
fi

SHAVE_INIT(.,enable)

AC_OUTPUT([
	Makefile
	man/Makefile
	src/Makefile
	utils/conntest/Makefile
])
if test "x$USE_DRI" != xyes ; then
  echo ""
  echo "NOTE: DRI support is disabled"
  echo ""
fi