Allow conditional builds without X11.
[hwdecode-demos:vj-hwdecode-demos.git] / configure.ac
1 # hwdecode_demos package version number
2 m4_define([hwdecode_demos_major_version], [0])
3 m4_define([hwdecode_demos_minor_version], [9])
4 m4_define([hwdecode_demos_micro_version], [6])
5 m4_define([hwdecode_demos_pre_version],   [1])
6 m4_define([hwdecode_demos_version],
7           [hwdecode_demos_major_version.hwdecode_demos_minor_version.hwdecode_demos_micro_version])
8 m4_if(hwdecode_demos_pre_version, [0], [], [
9 m4_append([hwdecode_demos_version], hwdecode_demos_pre_version, [.pre])
10 ])
11
12 AC_PREREQ([2.57])
13 AC_INIT([hwdecode_demos], [hwdecode_demos_version], [gbeauchesne@splitted-desktop.com], [hwdecode-demos])
14 AC_CONFIG_SRCDIR([Makefile.am])
15 AM_INIT_AUTOMAKE
16
17 AM_CONFIG_HEADER([src/config.h])
18
19 HWDECODE_DEMOS_MAJOR_VERSION=hwdecode_demos_major_version
20 HWDECODE_DEMOS_MINOR_VERSION=hwdecode_demos_minor_version
21 HWDECODE_DEMOS_MICRO_VERSION=hwdecode_demos_micro_version
22 AC_DEFINE([HWDECODE_DEMOS_MAJOR_VERSION], [hwdecode_demos_major_version], [Major version of the driver])
23 AC_DEFINE([HWDECODE_DEMOS_MINOR_VERSION], [hwdecode_demos_minor_version], [Minor version of the driver])
24 AC_DEFINE([HWDECODE_DEMOS_MICRO_VERSION], [hwdecode_demos_micro_version], [Micro version of the driver])
25 AC_DEFINE([HWDECODE_DEMOS_PRE_VERSION], [hwdecode_demos_pre_version], [Preversion of the driver])
26
27 dnl Use pretty build output with automake >= 1.11
28 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [
29   AM_DEFAULT_VERBOSITY=1
30   AC_SUBST(AM_DEFAULT_VERBOSITY)
31 ])
32
33 AC_ARG_ENABLE(ffmpeg,
34               AC_HELP_STRING([--enable-ffmpeg],
35                              [enable FFmpeg @<:@default=yes@:>@]),
36               [], [enable_ffmpeg="yes"])
37 AC_ARG_ENABLE(crystalhd,
38               AC_HELP_STRING([--enable-crystalhd],
39                              [enable Crystal HD @<:@default=yes@:>@]),
40               [], [enable_crystalhd="yes"])
41 AC_ARG_ENABLE(vaapi,
42               AC_HELP_STRING([--enable-vaapi],
43                              [enable VA-API @<:@default=yes@:>@]),
44               [], [enable_vaapi="yes"])
45 AC_ARG_ENABLE(vdpau,
46               AC_HELP_STRING([--enable-vdpau],
47                              [enable VDPAU @<:@default=yes@:>@]),
48               [], [enable_vdpau="yes"])
49 AC_ARG_ENABLE(xvba,
50               AC_HELP_STRING([--enable-xvba],
51                              [enable XvBA @<:@default=yes@:>@]),
52               [], [enable_xvba="yes"])
53
54 AC_ARG_ENABLE(drm,
55               AC_HELP_STRING([--enable-drm],
56                              [enable DRM backend @<:@default=yes@:>@]),
57               [], [enable_drm="yes"])
58 AC_ARG_ENABLE(x11,
59               AC_HELP_STRING([--enable-x11],
60                              [enable X11 backend @<:@default=yes@:>@]),
61               [], [enable_x11="yes"])
62 AC_ARG_ENABLE(glx,
63               AC_HELP_STRING([--enable-glx],
64                              [enable GLX backend @<:@default=yes@:>@]),
65               [], [enable_glx="yes"])
66
67 AC_ARG_WITH(libva,
68             AC_HELP_STRING([--with-libva=PREFIX],
69                            [build against libva in the specified PREFIX]),
70             [], [with_libva="pkgconfig"])
71
72 AC_DISABLE_STATIC
73 AC_PROG_LIBTOOL
74 AC_PROG_CC
75 AM_PROG_CC_C_O
76
77 AC_C_BIGENDIAN
78 AC_HEADER_STDC
79 AC_SYS_LARGEFILE
80
81 dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
82 HAVE_PTHREADS=yes
83 AC_CHECK_LIB(pthread, pthread_create, , [
84     AC_CHECK_LIB(c_r, pthread_create, , [
85         AC_CHECK_LIB(PTL, pthread_create, , [
86             HAVE_PTHREADS=no
87         ])
88     ])
89 ])
90 if test "$HAVE_PTHREADS" = "yes"; then
91     AC_DEFINE(HAVE_PTHREADS, 1, [Defined if pthreads are available])
92 fi
93
94 dnl Checks for libraries.
95 AC_CHECK_LIB(rt, timer_create)
96
97 dnl Checks for library functions.
98 AC_CHECK_FUNCS(clock_gettime)
99
100 dnl Check for FFmpeg
101 PKG_CHECK_MODULES(LIBAVUTIL, [libavutil],
102     [ac_cv_have_avutil="yes"],
103     [ac_cv_have_avutil="no"]
104 )
105 if test "$ac_cv_have_avutil" = "yes"; then
106     AC_DEFINE(HAVE_AVUTIL, 1, [Defined if libavutil is available])
107 fi
108 AC_CHECK_HEADERS([libavutil/pixfmt.h ffmpeg/avutil.h])
109
110 PKG_CHECK_MODULES(LIBAVFORMAT, [libavformat],
111     [ac_cv_have_avformat="yes"],
112     [ac_cv_have_avformat="no"]
113 )
114 if test "$ac_cv_have_avformat" = "yes"; then
115     AC_DEFINE(HAVE_AVFORMAT, 1, [Defined if libavformat is available])
116 fi
117 AC_CHECK_HEADERS([libavformat/avformat.h ffmpeg/avformat.h])
118
119 PKG_CHECK_MODULES(LIBAVCODEC, [libavcodec],
120     [ac_cv_have_avcodec="yes"],
121     [ac_cv_have_avcodec="no"]
122 )
123 if test "$ac_cv_have_avcodec" = "yes"; then
124     AC_DEFINE(HAVE_AVCODEC, 1, [Defined if libavcodec is available])
125 fi
126 AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h])
127 AC_CHECK_HEADERS([libavcodec/vaapi.h])
128
129 PKG_CHECK_MODULES(LIBSWSCALE, [libswscale],
130     [ac_cv_have_swscale="yes"],
131     [ac_cv_have_swscale="no"]
132 )
133 if test "$ac_cv_have_swscale" = "yes"; then
134     AC_DEFINE(HAVE_SWSCALE, 1, [Defined if libswscale is available])
135 fi
136 AC_CHECK_HEADERS([libswscale/swscale.h ffmpeg/swscale.h])
137
138 AM_CONDITIONAL(USE_FFMPEG, test "$enable_ffmpeg:$ac_cv_have_avformat:$ac_cv_have_swscale:$ac_cv_have_avcodec" = "yes:yes:yes:yes")
139
140 dnl Check for Cairo
141 PKG_CHECK_MODULES(CAIRO, [cairo],
142     [ac_cv_have_cairo="yes"],
143     [ac_cv_have_cairo="no"]
144 )
145 if test "$ac_cv_have_cairo" = "yes"; then
146     AC_DEFINE(HAVE_CAIRO, 1, [Defined if cairo is available])
147 fi
148 AM_CONDITIONAL(USE_CAIRO, test "$ac_cv_have_cairo" = "yes")
149
150 dnl Check for DRM/libudev
151 USE_DRM="no"
152 if test "$enable_drm" = "yes"; then
153     PKG_CHECK_MODULES(DRM, [libdrm], [USE_DRM="yes"], [USE_DRM="no"])
154     PKG_CHECK_MODULES(UDEV, [libudev], [:], [USE_DRM="no"])
155
156     if test "$USE_DRM" = "yes"; then
157         saved_CPPFLAGS="$CPPFLAGS"
158         CPPFLAGS="$CPPFLAGS $DRM_CFLAGS"
159         AC_CHECK_HEADERS([drm_fourcc.h], [:], [USE_DRM="no"])
160         CPPFLAGS="$saved_CPPFLAGS"
161     fi
162 fi
163 AM_CONDITIONAL(USE_DRM, [test "$USE_DRM" = "yes"])
164 if test "$USE_DRM" = "yes"; then
165     AC_DEFINE(USE_DRM, 1, [Defined if DRM is enabled])
166 fi
167
168 dnl Check for X11
169 USE_X11="no"
170 PKG_CHECK_MODULES(X11_DEPS, [x11], [HAVE_X11="yes"], [HAVE_X11="no"])
171 if test "$enable_x11" = "yes" -a "$HAVE_X11" = "yes"; then
172     USE_X11="yes"
173     AC_SUBST(X11_DEPS_CFLAGS)
174     AC_SUBST(X11_DEPS_LIBS)
175 fi
176 AM_CONDITIONAL(USE_X11, [test "$USE_X11" = "yes"])
177 if test "$USE_X11" = "yes"; then
178     AC_DEFINE(USE_X11, 1, [Defined if X11 is enabled])
179 else
180     enable_glx="no"
181     enable_vdpau="no"
182     enable_xvba="no"
183 fi
184
185 dnl Check for OpenGL
186 HAVE_GL="no"
187 HAVE_GLU="no"
188 PKG_CHECK_MODULES(GL_DEPS,  [gl],  [HAVE_GL="yes"],  [HAVE_GL="no"])
189 if test "$HAVE_GL" = "yes"; then
190     saved_CPPFLAGS="$CPPFLAGS"
191     CPPFLAGS="$CPPFLAGS $GL_DEPS_CFLAGS"
192     AC_CHECK_HEADERS([GL/gl.h], [:], [HAVE_GL="no"])
193     CPPFLAGS="$saved_CPPFLAGS"
194 fi
195
196 dnl Check for GLU
197 HAVE_GLU="no"
198 PKG_CHECK_MODULES(GLU_DEPS, [glu], [HAVE_GLU="yes"], [HAVE_GLU="no"])
199 if test "$HAVE_GLU" = "yes"; then
200     saved_CPPFLAGS="$CPPFLAGS"
201     CPPFLAGS="$CPPFLAGS $GLU_DEPS_CFLAGS"
202     AC_CHECK_HEADERS([GL/glu.h], [:], [HAVE_GLU="no"])
203     CPPFLAGS="$saved_CPPFLAGS"
204 fi
205
206 dnl Check for GLX
207 USE_GLX="no"
208 if test "$enable_glx" = "yes" -a "$HAVE_GL:$HAVE_GLU" = "yes:yes"; then
209     saved_CPPFLAGS="$CPPFLAGS"
210     saved_LIBS="$LIBS"
211     CPPFLAGS="$CPPFLAGS $GL_DEPS_CFLAGS $GLU_DEPS_CFLAGS $X11_DEPS_CFLAGS"
212     LIBS="$LIBS $GL_DEPS_LIBS $GLU_DEPS_LIBS $X11_DEPS_LIBS"
213     USE_GLX="yes"
214     AC_CHECK_HEADERS([GL/glx.h], [:], [USE_GLX="no"])
215     AC_CHECK_LIB([GL], [glXCreateContext], [:], [USE_GLX="no"])
216     AC_CHECK_LIB([GLU], [gluPerspective], [:], [USE_GLX="no"])
217     CPPFLAGS="$saved_CPPFLAGS"
218     LIBS="$saved_LIBS"
219 fi
220 AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes")
221 if test "$USE_GLX" = "yes"; then
222     AC_DEFINE(USE_GLX, 1, [Defined if GLX is enabled])
223 fi
224
225 dnl Check for Crystal HD
226 AC_CACHE_CHECK([for Crystal HD],
227     ac_cv_have_crystalhd, [
228     for incdir in /usr/include /usr/local/include; do
229         CRYSTALHD_CFLAGS="-I${incdir}/libcrystalhd -D__LINUX_USER__"
230         CRYSTALHD_LIBS="-lcrystalhd"
231         saved_CFLAGS="$CFLAGS"
232         CFLAGS="$CFLAGS $CRYSTALHD_CFLAGS"
233         saved_LIBS="$LIBS"
234         LIBS="$LIBS $CRYSTALHD_LIBS"
235         AC_TRY_LINK(
236         [#include <libcrystalhd_if.h>],
237         [DtsDeviceOpen(0, 0)],
238         [ac_cv_have_crystalhd="yes"],
239         [ac_cv_have_crystalhd="no"])
240         CFLAGS="$saved_CFLAGS"
241         LIBS="$saved_LIBS"
242         if test "$ac_cv_have_crystalhd" = "yes"; then
243             break
244         fi
245     done
246 ])
247 USE_CRYSTALHD="no"
248 if test "$enable_crystalhd:$ac_cv_have_crystalhd" = "yes:yes"; then
249     USE_CRYSTALHD="yes"
250 fi
251 AC_SUBST(CRYSTALHD_CFLAGS)
252 AC_SUBST(CRYSTALHD_LIBS)
253 AM_CONDITIONAL(USE_CRYSTALHD, test "$USE_CRYSTALHD" = "yes")
254
255 dnl Check for VA-API
256 AC_CACHE_CHECK([for old libVA API 0.29],
257     ac_cv_have_old_vaapi, [
258     saved_LIBS="$LIBS"
259     LIBS="$LIBS -lva"
260     AC_TRY_LINK(
261     [#include <va_x11.h>],
262     [vaGetDisplay(NULL)],
263     [ac_cv_have_old_vaapi="yes"],
264     [ac_cv_have_old_vaapi="no"])
265     LIBS="$saved_LIBS"
266 ])
267 USE_OLD_VAAPI="no"
268 if test "$enable_vaapi:$ac_cv_have_old_vaapi" = "yes:yes"; then
269     USE_VAAPI="yes"
270     USE_OLD_VAAPI="yes"
271     OLD_VAAPI_LIBS="-lva"
272 fi
273 AC_SUBST(OLD_VAAPI_CFLAGS)
274 AC_SUBST(OLD_VAAPI_LIBS)
275 AM_CONDITIONAL(USE_OLD_VAAPI, test "$USE_OLD_VAAPI" = "yes")
276
277 if test "$USE_DRM" = "yes"; then
278     if test "$with_libva" = "pkgconfig"; then
279         PKG_CHECK_MODULES(VAAPI_DRM_DEPS, [libva-drm],
280             [ac_cv_have_vaapi_drm="yes"],
281             [ac_cv_have_vaapi_drm="no"]
282         )
283     else
284         AC_CACHE_CHECK([for VA-API (drm) in ${with_libva}],
285             ac_cv_have_vaapi_drm, [
286             saved_CFLAGS="$CFLAGS"
287             saved_LIBS="$LIBS"
288             for lib in lib lib32 lib64; do
289                 VAAPI_DRM_DEPS_CFLAGS="-I${with_libva}/include"
290                 VAAPI_DRM_DEPS_LIBS="-L${with_libva}/$lib -lva-drm -lva"
291                 CFLAGS="$saved_CFLAGS $VAAPI_DRM_DEPS_CFLAGS"
292                 LIBS="$saved_LIBS $VAAPI_DRM_DEPS_LIBS"
293                 AC_TRY_LINK(
294                     [#include <va/va_drm.h>],
295                     [vaGetDisplayDRM(0)],
296                     [ac_cv_have_vaapi_drm="yes"; break],
297                     [ac_cv_have_vaapi_drm="no"]
298                 )
299             done
300             CFLAGS="$saved_CFLAGS"
301             LIBS="$saved_LIBS"
302         ])
303     fi
304 fi
305 USE_VAAPI_DRM="no"
306 if test "$USE_DRM:$enable_vaapi:$ac_cv_have_vaapi_drm" = "yes:yes:yes"; then
307     USE_VAAPI="yes"
308     USE_VAAPI_DRM="yes"
309 fi
310 AM_CONDITIONAL(USE_VAAPI_DRM, [test "$USE_VAAPI_DRM" = "yes"])
311
312 if test "$USE_X11" = "yes"; then
313     if test "$with_libva" = "pkgconfig"; then
314         PKG_CHECK_MODULES(VAAPI_X11_DEPS, [libva-x11],
315             [ac_cv_have_vaapi_x11="yes"],
316             [ac_cv_have_vaapi_x11="no"]
317         )
318     else
319         AC_CACHE_CHECK([for VA-API (x11) in ${with_libva}],
320             ac_cv_have_vaapi_x11, [
321             saved_CFLAGS="$CFLAGS"
322             saved_LIBS="$LIBS"
323             for lib in lib lib32 lib64; do
324                 VAAPI_X11_DEPS_CFLAGS="-I${with_libva}/include"
325                 VAAPI_X11_DEPS_LIBS="-L${with_libva}/$lib -lva-x11 -lva"
326                 CFLAGS="$saved_CFLAGS $VAAPI_X11_DEPS_CFLAGS"
327                 LIBS="$saved_LIBS $VAAPI_X11_DEPS_LIBS"
328                 AC_TRY_LINK(
329                     [#include <va/va_x11.h>],
330                     [vaGetDisplay(NULL)],
331                     [ac_cv_have_vaapi_x11="yes"; break],
332                     [ac_cv_have_vaapi_x11="no"]
333                 )
334             done
335             CFLAGS="$saved_CFLAGS"
336             LIBS="$saved_LIBS"
337         ])
338     fi
339 fi
340 USE_VAAPI_X11="no"
341 if test "$USE_X11:$enable_vaapi:$ac_cv_have_vaapi_x11" = "yes:yes:yes"; then
342     USE_VAAPI="yes"
343     USE_VAAPI_X11="yes"
344 fi
345 AM_CONDITIONAL(USE_VAAPI_X11, [test "$USE_VAAPI_X11" = "yes"])
346
347 if test "$USE_GLX" = "yes"; then
348     if test "$with_libva" = "pkgconfig"; then
349         PKG_CHECK_MODULES(VAAPI_GLX_DEPS, [libva-glx],
350             [ac_cv_have_vaapi_glx="yes"],
351             [ac_cv_have_vaapi_glx="no"]
352         )
353     else
354         AC_CACHE_CHECK([for VA-API (glx) in ${with_libva}],
355             ac_cv_have_vaapi_glx, [
356             saved_CFLAGS="$CFLAGS"
357             saved_LIBS="$LIBS"
358             for lib in lib lib32 lib64; do
359                 VAAPI_GLX_DEPS_CFLAGS="-I${with_libva}/include"
360                 VAAPI_GLX_DEPS_LIBS="-L${with_libva}/$lib -lva-glx -lva"
361                 CFLAGS="$saved_CFLAGS $VAAPI_GLX_DEPS_CFLAGS"
362                 LIBS="$saved_LIBS $VAAPI_GLX_DEPS_LIBS"
363                 AC_TRY_LINK(
364                     [#include <va/va_glx.h>],
365                     [vaGetDisplayGLX(NULL)],
366                     [ac_cv_have_vaapi_glx="yes"; break],
367                     [ac_cv_have_vaapi_glx="no"]
368                 )
369             done
370             CFLAGS="$saved_CFLAGS"
371             LIBS="$saved_LIBS"
372         ])
373     fi
374 fi
375 USE_VAAPI_GLX="no"
376 if test "$USE_GLX:$enable_vaapi:$ac_cv_have_vaapi_glx" = "yes:yes:yes"; then
377     USE_VAAPI="yes"
378     USE_VAAPI_GLX="yes"
379 fi
380 AM_CONDITIONAL(USE_VAAPI_GLX, [test "$USE_VAAPI_GLX" = "yes"])
381
382 AM_CONDITIONAL(USE_VAAPI, [test "$USE_VAAPI" = "yes"])
383
384 dnl Check for VDPAU
385 AC_CACHE_CHECK([for VDPAU],
386     ac_cv_have_vdpau, [
387     saved_LIBS="$LIBS"
388     LIBS="$LIBS -lvdpau"
389     AC_TRY_LINK(
390     [#include <vdpau/vdpau_x11.h>],
391     [vdp_device_create_x11(0,0,0,0)],
392     [ac_cv_have_vdpau="yes" VDPAU_DEPS_LIBS="-lvdpau"],
393     [ac_cv_have_vdpau="no"])
394     LIBS="$saved_LIBS"
395 ])
396 AC_SUBST(VDPAU_DEPS_CFLAGS)
397 AC_SUBST(VDPAU_DEPS_LIBS)
398 AM_CONDITIONAL(USE_VDPAU, test "$enable_vdpau:$ac_cv_have_vdpau" = "yes:yes")
399
400 AC_CACHE_CHECK([for VDPAU/MPEG-4 support],
401     ac_cv_have_vdpau_mpeg4, [
402     saved_LIBS="$LIBS"
403     LIBS="$LIBS -lvdpau"
404     AC_TRY_LINK(
405     [#include <vdpau/vdpau.h>],
406     [VdpPictureInfoMPEG4Part2 pic_info],
407     [ac_cv_have_vdpau_mpeg4="yes" HAVE_VDPAU_MPEG4=1],
408     [ac_cv_have_vdpau_mpeg4="no"  HAVE_VDPAU_MPEG4=0])
409     LIBS="$saved_LIBS"
410 ])
411 AC_DEFINE_UNQUOTED(HAVE_VDPAU_MPEG4, [$HAVE_VDPAU_MPEG4], [VDPAU/MPEG-4 support])
412 AM_CONDITIONAL(USE_VDPAU_MPEG4, test "$ac_cv_have_vdpau_mpeg4" = "yes")
413
414 dnl Check for XvBA
415 AC_CACHE_CHECK([for XvBA],
416     ac_cv_have_xvba, [
417     saved_LIBS="$LIBS"
418     LIBS="$LIBS -lXvBAW"
419     LIBS="$LIBS -lGL -ldl" # XXX: help broken XvBA libraries...
420     AC_TRY_LINK(
421     [
422 #include <X11/Xlib.h>
423 #include <amdpcom.h>
424 #include <amdxvba.h>
425     ],
426     [XVBAQueryExtension(0,0)],
427     [ac_cv_have_xvba="yes" XVBA_DEPS_LIBS="-lXvBAW -lGL -ldl"],
428     [ac_cv_have_xvba="no"])
429     LIBS="$saved_LIBS"
430 ])
431 AC_SUBST(XVBA_DEPS_CFLAGS)
432 AC_SUBST(XVBA_DEPS_LIBS)
433 AM_CONDITIONAL(USE_XVBA, test "$enable_xvba:$ac_cv_have_xvba" = "yes:yes")
434
435 AC_OUTPUT([
436     Makefile
437     src/Makefile
438 ])