0.3.4.
[vaapi:gstreamer-vaapi.git] / configure.ac
1 # gstreamer-vaapi package version number
2 m4_define([gst_vaapi_major_version], [0])
3 m4_define([gst_vaapi_minor_version], [3])
4 m4_define([gst_vaapi_micro_version], [4])
5 m4_define([gst_vaapi_pre_version],   [0])
6 m4_define([gst_vaapi_version],
7           [gst_vaapi_major_version.gst_vaapi_minor_version.gst_vaapi_micro_version])
8 m4_if(gst_vaapi_pre_version, [0], [], [
9 m4_append([gst_vaapi_version], gst_vaapi_pre_version, [.pre])
10 ])
11
12 # gst version number
13 m4_define([gst_major_version], [0])
14 m4_define([gst_minor_version], [10])
15 m4_define([gst_micro_version], [10])
16 m4_define([gst_major_minor_version],
17           [gst_major_version.gst_minor_version])
18 m4_define([gst_version],
19           [gst_major_version.gst_minor_version.gst_micro_version])
20
21 # gst plugins-base version number
22 m4_define([gst_plugins_base_major_version], [0])
23 m4_define([gst_plugins_base_minor_version], [10])
24 m4_define([gst_plugins_base_micro_version], [16])
25 m4_define([gst_plugins_base_version],
26           [gst_plugins_base_major_version.gst_plugins_base_minor_version.gst_plugins_base_micro_version])
27
28 # VA-API minimum version number
29 m4_define([va_api_x11_version], [0.31.0])
30 m4_define([va_api_glx_version], [0.32.0])
31
32 # gst plugins-bad version number
33 m4_define([gst_plugins_bad_major_version], [0])
34 m4_define([gst_plugins_bad_minor_version], [10])
35 m4_define([gst_plugins_bad_micro_version], [22])
36 m4_define([gst_plugins_bad_version],
37           [gst_plugins_bad_major_version.gst_plugins_bad_minor_version.gst_plugins_bad_micro_version])
38
39 # libva package version number
40 m4_define([libva_x11_package_version], [1.0.3])
41 m4_define([libva_glx_package_version], [1.0.9])
42
43 # gtk-doc version number
44 # XXX: introspection annotations require gtk-doc >= 1.12
45 m4_define([gtkdoc_major_version], [1])
46 m4_define([gtkdoc_minor_version], [9])
47 m4_define([gtkdoc_version], [gtkdoc_major_version.gtkdoc_minor_version])
48
49 AC_PREREQ([2.57])
50 AC_INIT([gst_vaapi], [gst_vaapi_version],
51     [gwenole.beauchesne@intel.com],
52     [gstreamer-vaapi])
53 AC_CONFIG_SRCDIR([Makefile.am])
54 AC_CANONICAL_TARGET
55 AM_INIT_AUTOMAKE
56 AM_CONFIG_HEADER([config.h])
57
58 TODAY="`LC_ALL=C date +'%a, %d %b %Y %X %z'`"
59 AC_SUBST(TODAY)
60
61 GST_VAAPI_MAJOR_VERSION=gst_vaapi_major_version
62 AC_SUBST(GST_VAAPI_MAJOR_VERSION)
63
64 LIBVA_PACKAGE_VERSION=libva_x11_package_version
65 AC_SUBST(LIBVA_PACKAGE_VERSION)
66
67 dnl Versions for GStreamer and plugins-base
68 GST_MAJORMINOR=gst_major_minor_version
69 GST_VERSION_REQUIRED=gst_version
70 GST_PLUGINS_BASE_VERSION_REQUIRED=gst_plugins_base_version
71 GST_PLUGINS_BAD_VERSION_REQUIRED=gst_plugins_bad_version
72 AC_SUBST(GST_MAJORMINOR)
73 AC_SUBST(GST_VERSION_REQUIRED)
74 AC_SUBST(GST_PLUGINS_BASE_VERSION_REQUIRED)
75
76 dnl Use pretty build output with automake >= 1.11
77 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [
78   AM_DEFAULT_VERBOSITY=1
79   AC_SUBST(AM_DEFAULT_VERBOSITY)
80 ])
81
82 dnl Check for tools
83 AC_PROG_CC
84 AM_PROG_CC_C_O
85 AC_PROG_LIBTOOL
86
87 AC_ARG_ENABLE(glx,
88     AC_HELP_STRING([--enable-glx],
89                    [enable OpenGL/X11 @<:@default=yes@:>@]),
90     [], [enable_glx="yes"])
91
92 AC_ARG_ENABLE(vaapi-glx,
93     AC_HELP_STRING([--enable-vaapi-glx],
94                    [enable VA/GLX extensions @<:@default=yes@:>@]),
95     [], [enable_vaapi_glx="yes"])
96
97 AC_ARG_ENABLE(vaapisink-glx,
98     AC_HELP_STRING([--enable-vaapisink-glx],
99                    [enable OpenGL/X11 to vaapisink @<:@default=yes@:>@]),
100     [], [enable_vaapisink_glx="no"])
101
102 AC_ARG_ENABLE(ffmpeg,
103     AC_HELP_STRING([--enable-ffmpeg],
104                    [enable bitstream parsing from FFmpeg @<:@default=yes@:>@]),
105     [], [enable_ffmpeg="yes"])
106
107 AC_ARG_ENABLE(codecparsers,
108     AC_HELP_STRING([--enable-codecparsers],
109                    [enable adhoc bitstream parsers from GStreamer @<:@default=yes@:>@]),
110     [], [enable_codecparsers="yes"])
111
112 dnl Check for __attribute__((visibility()))
113 AC_CACHE_CHECK([whether __attribute__((visibility())) is supported],
114   vaapi_cv_visibility_attribute,
115   [cat > conftest.c <<EOF
116 int foo __attribute__ ((visibility ("hidden"))) = 1;
117 int bar __attribute__ ((visibility ("protected"))) = 1;
118 EOF
119   vaapi_cv_visibility_attribute=no
120   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
121     if grep '\.hidden.*foo' conftest.s >/dev/null; then
122       if grep '\.protected.*bar' conftest.s >/dev/null; then
123         vaapi_cv_visibility_attribute=yes
124       fi
125     fi
126   fi
127   rm -f conftest.[cs]
128 ])
129 if test $vaapi_cv_visibility_attribute = yes; then
130   vaapi_cv_visibility_attribute_hidden="__attribute__((visibility(\"hidden\")))"
131 else
132   vaapi_cv_visibility_attribute_hidden=""
133 fi
134 AC_DEFINE_UNQUOTED([attribute_hidden],
135                    [$vaapi_cv_visibility_attribute_hidden],
136                    [Define the "hidden" visibility attribute])
137
138 dnl Check for basic libraries
139 AC_CHECK_LIB(m, tan)
140
141 dnl Check for Gtk doc
142 GTKDOC_VERSION=gtkdoc_version
143 GTK_DOC_CHECK([$GTKDOC_VERSION])
144 AM_CONDITIONAL([BUILD_GTK_DOC], [test "x$enable_gtk_doc" = "xyes"])
145 AC_SUBST(GTKDOC_VERSION)
146
147 dnl Check for GLib
148 AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
149 PKG_CHECK_MODULES([GLIB], [glib-2.0])
150 AC_CHECK_LIB([glib-2.0], [g_list_free_full], [
151     AC_DEFINE([HAVE_G_LIST_FREE_FULL], [1],
152               [Define to 1 if g_list_free_full() is available.])])
153 AC_SUBST(GLIB_CFLAGS)
154 AC_SUBST(GLIB_LIBS)
155
156 dnl Check for GStreamer
157 PKG_CHECK_MODULES([GST],
158     [gstreamer-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED]
159 )
160 AC_SUBST(GST_CFLAGS)
161 AC_SUBST(GST_LIBS)
162
163 AC_CACHE_CHECK([for GstBaseSink::query hook], ac_cv_have_gst_base_sink_query, [
164     saved_CFLAGS="$CFLAGS"
165     CFLAGS="$CFLAGS $GST_CFLAGS"
166     saved_LIBS="$LIBS"
167     LIBS="$LIBS $GST_LIBS"
168     AC_TRY_COMPILE(
169         [#include <gst/base/gstbasesink.h>],
170         [GstBaseSinkClass klass; klass.query = NULL;],
171         [ac_cv_have_gst_base_sink_query="yes"],
172         [ac_cv_have_gst_base_sink_query="no"]
173     )
174     CFLAGS="$saved_CFLAGS"
175     LIBS="$saved_LIBS"
176 ])
177 if test "$ac_cv_have_gst_base_sink_query" != "yes"; then
178     AC_MSG_ERROR([GstBaseSink does not contain the 'query' vfunc])
179 fi
180
181 dnl Check for GStreamer plugins-base
182 PKG_CHECK_MODULES([GST_PLUGINS_BASE],
183     [gstreamer-plugins-base-$GST_MAJORMINOR >= $GST_PLUGINS_BASE_VERSION_REQUIRED]
184 )
185 AC_SUBST(GST_PLUGINS_BASE_CFLAGS)
186 AC_SUBST(GST_PLUGINS_BASE_LIBS)
187
188 V=`$PKG_CONFIG --modversion gstreamer-plugins-base-$GST_MAJORMINOR`
189 GST_PLUGINS_BASE_MAJOR_VERSION=`echo "$V" | cut -d'.' -f1`
190 GST_PLUGINS_BASE_MINOR_VERSION=`echo "$V" | cut -d'.' -f2`
191 GST_PLUGINS_BASE_MICRO_VERSION=`echo "$V" | cut -d'.' -f3`
192 AC_SUBST(GST_PLUGINS_BASE_MAJOR_VERSION)
193 AC_SUBST(GST_PLUGINS_BASE_MINOR_VERSION)
194 AC_SUBST(GST_PLUGINS_BASE_MICRO_VERSION)
195
196 dnl Check for GStreamer base
197 PKG_CHECK_MODULES([GST_BASE],
198     [gstreamer-base-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED]
199 )
200 AC_SUBST(GST_BASE_CFLAGS)
201 AC_SUBST(GST_BASE_LIBS)
202
203 dnl Check for GStreamer video
204 PKG_CHECK_MODULES([GST_VIDEO],
205     [gstreamer-video-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED]
206 )
207 AC_SUBST(GST_VIDEO_CFLAGS)
208 AC_SUBST(GST_VIDEO_LIBS)
209
210 AC_CACHE_CHECK([for GstVideoOverlayComposition],
211     ac_cv_have_gst_video_overlay_composition, [
212     saved_CFLAGS="$CFLAGS"
213     CFLAGS="$CFLAGS $GST_CFLAGS"
214     saved_LIBS="$LIBS"
215     LIBS="$LIBS $GST_LIBS"
216     AC_TRY_COMPILE(
217         [#include <gst/video/video-overlay-composition.h>],
218         [GstVideoOverlayComposition *c = gst_video_overlay_composition_new(0);],
219         [ac_cv_have_gst_video_overlay_composition="yes"],
220         [ac_cv_have_gst_video_overlay_composition="no"]
221     )
222     CFLAGS="$saved_CFLAGS"
223     LIBS="$saved_LIBS"
224 ])
225 if test "$ac_cv_have_gst_video_overlay_composition" != "yes"; then
226     AC_MSG_ERROR([GstVideoOverlayComposition is not available])
227 fi
228
229 dnl Check for GStreamer basevideo
230 PKG_CHECK_MODULES([GST_BASEVIDEO],
231     [gstreamer-basevideo-$GST_MAJORMINOR >= $GST_PLUGINS_BAD_VERSION_REQUIRED]
232 )
233 AC_SUBST(GST_BASEVIDEO_CFLAGS)
234 AC_SUBST(GST_BASEVIDEO_LIBS)
235
236 dnl Check for GStreamer codec parsers
237 USE_CODEC_PARSERS=0
238 if test "$enable_codecparsers" = "yes"; then
239 PKG_CHECK_MODULES([GST_CODEC_PARSERS],
240     [gstreamer-codecparsers-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED],
241     [enable_codecparsers="yes" USE_CODEC_PARSERS=1],
242     [enable_codecparsers="no"  USE_CODEC_PARSERS=0]
243 )
244 fi
245
246 AC_DEFINE_UNQUOTED(USE_CODEC_PARSERS, $USE_CODEC_PARSERS,
247     [Defined to 1 if GStreamer codec parsers are used])
248 AM_CONDITIONAL(USE_CODEC_PARSERS, test $USE_CODEC_PARSERS -eq 1)
249
250 dnl Check for GStreamer interfaces
251 PKG_CHECK_MODULES([GST_INTERFACES],
252     [gstreamer-interfaces-$GST_MAJORMINOR >= $GST_PLUGINS_BASE_VERSION_REQUIRED]
253 )
254 AC_SUBST(GST_INTERFACES_CFLAGS)
255 AC_SUBST(GST_INTERFACES_LIBS)
256
257 dnl GST_ALL_LDFLAGS:
258 dnl LDFLAGS really should only contain flags, not libs - they get added before
259 dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
260 GST_ALL_LDFLAGS="-no-undefined"
261 AC_SUBST(GST_ALL_LDFLAGS)
262
263 dnl GST_PLUGIN_LDFLAGS:
264 dnl this really should only contain flags, not libs - they get added before
265 dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
266 GST_PLUGIN_LDFLAGS="-module -avoid-version -export-symbols-regex '^([_]*gst_plugin_desc|gst_.*_get_type)\$\$' $GST_ALL_LDFLAGS"
267 AC_SUBST(GST_PLUGIN_LDFLAGS)
268
269 dnl Check for the GStreamer plugins directory
270 AC_MSG_CHECKING([for GStreamer plugins directory])
271 GST_PLUGINS_DIR=`$PKG_CONFIG gstreamer-$GST_MAJORMINOR --variable pluginsdir`
272 if test -z "$GST_PLUGINS_DIR"; then
273     echo "FAIL FAIL FAIL"
274     GST_PLUGINS_DIR="\$(libdir)/gstreamer-$GST_MAJORMINOR"
275 fi
276 AC_MSG_RESULT([$GST_PLUGINS_DIR])
277 plugindir="$GST_PLUGINS_DIR"
278 AC_SUBST(plugindir)
279
280 dnl Check for X11
281 PKG_CHECK_MODULES(X11, [x11])
282
283 dnl Check for OpenGL
284 USE_GLX=1
285 if test "$enable_glx" != "yes"; then
286     USE_GLX=0
287 fi
288 GLX_CFLAGS=""
289 GLX_LIBS=""
290 AC_CHECK_HEADERS([GL/gl.h GL/glext.h GL/glx.h], [], [USE_GLX=0], [
291 #ifdef HAVE_GL_GL_H
292 # include <GL/gl.h>
293 #endif
294 ])
295 AC_CHECK_LIB(GL, glXCreateContext, [GLX_LIBS="-lGL"], [USE_GLX=0])
296 AC_SUBST(GLX_CFLAGS)
297 AC_SUBST(GLX_LIBS)
298
299 dnl Check for VA-API
300 LIBVA_PKGNAME="libva"
301 PKG_CHECK_MODULES(LIBVA, [$LIBVA_PKGNAME])
302 AC_SUBST(LIBVA_PKGNAME)
303
304 dnl ... original VA-API 0.29
305 AC_CACHE_CHECK([for old VA-API 0.29],
306     ac_cv_have_vaapi_old, [
307     saved_CFLAGS="$CFLAGS"
308     CFLAGS="$CFLAGS $LIBVA_CFLAGS"
309     saved_LIBS="$LIBS"
310     LIBS="$LIBS $LIBVA_LIBS"
311     AC_TRY_LINK(
312     [#include <va_x11.h>],
313     [vaGetDisplay(NULL)],
314     [ac_cv_have_vaapi_old="yes"],
315     [ac_cv_have_vaapi_old="no"])
316     CFLAGS="$saved_CFLAGS"
317     LIBS="$saved_LIBS"
318 ])
319 if test "$ac_cv_have_vaapi_old" = "yes"; then
320     LIBVA_EXTRA_CFLAGS="$LIBVA_CFLAGS -DGST_VAAPI_USE_OLD_VAAPI_0_29"
321 fi
322
323 dnl ... VA-API >= 0.31 or -sds
324 LIBVA_X11_PKGNAME="libva-x11"
325 PKG_CHECK_MODULES(LIBVA_X11, [$LIBVA_X11_PKGNAME],
326     [ac_cv_have_vaapi_x11="yes"],
327     [ac_cv_have_vaapi_x11="no"]
328 )
329 if test "$ac_cv_have_vaapi_x11" = "no"; then
330     if test "$ac_cv_have_vaapi_old" = "yes"; then
331         LIBVA_X11_PKGNAME="libva"
332         CFLAGS="$CFLAGS $LIBVA_EXTRA_CFLAGS"
333         LIBS="$LIBS $LIBVA_EXTRA_LIBS"
334     else
335         AC_MSG_ERROR([could not find VA-API])
336     fi
337 fi
338 AC_SUBST(LIBVA_X11_PKGNAME)
339
340 dnl ... VA-API >= 0.31 or -sds (VA/GLX extensions)
341 USE_VAAPI_GLX=0
342 if test $USE_GLX -eq 1; then
343     if test "$enable_vaapi_glx" = "yes"; then
344         LIBVA_GLX_PKGNAME="libva-glx"
345         PKG_CHECK_MODULES(LIBVA_GLX, [$LIBVA_GLX_PKGNAME],
346             [ac_cv_have_vaapi_glx="yes" USE_VAAPI_GLX=1],
347             [ac_cv_have_vaapi_glx="no"]
348         )
349     fi
350     if test $USE_VAAPI_GLX -eq 0; then
351         AC_MSG_WARN([VA/GLX not found or disabled. Fallbacking to TFP+FBO])
352         LIBVA_GLX_PKGNAME="$LIBVA_X11_PKGNAME"
353     fi
354 fi
355 AC_SUBST(LIBVA_GLX_PKGNAME)
356
357 AC_SUBST(LIBVA_EXTRA_CFLAGS)
358 AC_SUBST(LIBVA_EXTRA_LIBS)
359
360 dnl Check for OpenGL support to vaapisink
361 if test "$enable_vaapisink_glx:$USE_GLX" = "yes:1"; then
362     USE_VAAPISINK_GLX=1
363 else
364     USE_VAAPISINK_GLX=0
365 fi
366
367 dnl Check for FFmpeg
368 USE_FFMPEG=0
369 if test "$enable_ffmpeg" = "yes"; then
370 PKG_CHECK_MODULES(LIBAVCODEC, [libavcodec],
371     [enable_ffmpeg="yes" USE_FFMPEG=1],
372     [enable_ffmpeg="no"  USE_FFMPEG=0]
373 )
374 fi
375 if test "$enable_ffmpeg" = "yes"; then
376 AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h])
377 AC_CHECK_HEADERS([libavcodec/vaapi.h ffmpeg/vaapi.h],
378     [break],
379     [enable_ffmpeg="no"  USE_FFMPEG=0]
380 )
381 fi
382
383 if test "$enable_ffmpeg:$enable_codecparsers" = "no:no"; then
384     AC_MSG_ERROR([Found neither suitable FFmpeg with VA-API support nor GStreamer bitstream parsers])
385 fi
386
387 AC_DEFINE_UNQUOTED(USE_FFMPEG, $USE_FFMPEG,
388     [Defined to 1 if FFmpeg is used])
389 AM_CONDITIONAL(USE_FFMPEG, test $USE_FFMPEG -eq 1)
390
391 AC_DEFINE_UNQUOTED(USE_GLX, $USE_GLX,
392     [Defined to 1 if GLX is enabled])
393 AM_CONDITIONAL(USE_GLX, test $USE_GLX -eq 1)
394
395 AC_DEFINE_UNQUOTED(USE_VAAPI_GLX, $USE_VAAPI_GLX,
396     [Defined to 1 if VA/GLX is enabled])
397 AM_CONDITIONAL(USE_VAAPI_GLX, test $USE_VAAPI_GLX -eq 1)
398
399 AC_DEFINE_UNQUOTED(USE_VAAPISINK_GLX, $USE_VAAPISINK_GLX,
400     [Defined to 1 to enable GLX support to vaapisink])
401 AM_CONDITIONAL(USE_VAAPISINK_GLX, test $USE_VAAPISINK_GLX -eq 1)
402
403 VA_VERSION=`$PKG_CONFIG --modversion libva`
404 VA_MAJOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f1`
405 VA_MINOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f2`
406 VA_MICRO_VERSION=`echo "$VA_VERSION" | cut -d'.' -f3`
407 VA_VERSION_STR="$VA_VERSION"
408
409 pkgconfigdir=${libdir}/pkgconfig
410 AC_SUBST(pkgconfigdir)
411
412 AC_OUTPUT([
413     Makefile
414     debian.upstream/Makefile
415     debian.upstream/changelog
416     debian.upstream/control
417     debian.upstream/gstreamer$GST_MAJORMINOR-vaapi.install:\
418 debian.upstream/gstreamer-vaapi.install.in
419     debian.upstream/gstreamer$GST_MAJORMINOR-vaapi-doc.install:\
420 debian.upstream/gstreamer-vaapi-doc.install.in
421     debian.upstream/libgstvaapi$GST_VAAPI_MAJOR_VERSION.install:\
422 debian.upstream/libgstvaapi.install.in
423     debian.upstream/libgstvaapi-dev.install
424     debian.upstream/libgstvaapi-x11-$GST_VAAPI_MAJOR_VERSION.install:\
425 debian.upstream/libgstvaapi-x11.install.in
426     debian.upstream/libgstvaapi-glx-$GST_VAAPI_MAJOR_VERSION.install:\
427 debian.upstream/libgstvaapi-glx.install.in
428     docs/Makefile
429     docs/reference/Makefile
430     docs/reference/libs/Makefile
431     docs/reference/libs/libs-docs.xml
432     docs/reference/plugins/Makefile
433     docs/reference/plugins/plugins-docs.xml
434     gst-libs/Makefile
435     gst-libs/gst/Makefile
436     gst-libs/gst/gstutils_version.h
437     gst-libs/gst/vaapi/Makefile
438     pkgconfig/Makefile
439     pkgconfig/gstreamer-vaapi-$GST_MAJORMINOR.pc:\
440 pkgconfig/gstreamer-vaapi.pc.in
441     pkgconfig/gstreamer-vaapi-glx-$GST_MAJORMINOR.pc:\
442 pkgconfig/gstreamer-vaapi-glx.pc.in
443     pkgconfig/gstreamer-vaapi-x11-$GST_MAJORMINOR.pc:\
444 pkgconfig/gstreamer-vaapi-x11.pc.in
445     gst/Makefile
446     gst/vaapi/Makefile
447     tests/Makefile
448 ])
449
450 dnl Print summary
451 yesno() {
452     test $1 -eq 1 && echo yes || echo no
453 }
454
455 echo
456 echo $PACKAGE configuration summary:
457 echo
458 echo VA-API version ................... : $VA_VERSION_STR
459 echo GLX support ...................... : $(yesno $USE_GLX)
460 echo VA/GLX support ................... : $(yesno $USE_VAAPI_GLX)
461 echo VaapiSink/GL ..................... : $(yesno $USE_VAAPISINK_GLX)
462 echo FFmpeg bitstream parsers ......... : $(yesno $USE_FFMPEG)
463 echo GStreamer bitstream parsers ...... : $(yesno $USE_CODEC_PARSERS)
464 echo