configure: check for GstVideoOverlayComposition.
[platform/upstream/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], [1])
5 m4_define([gst_vaapi_pre_version],   [1])
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 dnl Check for __attribute__((visibility()))
103 AC_CACHE_CHECK([whether __attribute__((visibility())) is supported],
104   vaapi_cv_visibility_attribute,
105   [cat > conftest.c <<EOF
106 int foo __attribute__ ((visibility ("hidden"))) = 1;
107 int bar __attribute__ ((visibility ("protected"))) = 1;
108 EOF
109   vaapi_cv_visibility_attribute=no
110   if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
111     if grep '\.hidden.*foo' conftest.s >/dev/null; then
112       if grep '\.protected.*bar' conftest.s >/dev/null; then
113         vaapi_cv_visibility_attribute=yes
114       fi
115     fi
116   fi
117   rm -f conftest.[cs]
118 ])
119 if test $vaapi_cv_visibility_attribute = yes; then
120   vaapi_cv_visibility_attribute_hidden="__attribute__((visibility(\"hidden\")))"
121 else
122   vaapi_cv_visibility_attribute_hidden=""
123 fi
124 AC_DEFINE_UNQUOTED([attribute_hidden],
125                    [$vaapi_cv_visibility_attribute_hidden],
126                    [Define the "hidden" visibility attribute])
127
128 dnl Check for basic libraries
129 AC_CHECK_LIB(m, tan)
130
131 dnl Check for Gtk doc
132 GTKDOC_VERSION=gtkdoc_version
133 GTK_DOC_CHECK([$GTKDOC_VERSION])
134 AM_CONDITIONAL([BUILD_GTK_DOC], [test "x$enable_gtk_doc" = "xyes"])
135 AC_SUBST(GTKDOC_VERSION)
136
137 dnl Check for GLib
138 AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
139 PKG_CHECK_MODULES([GLIB], [glib-2.0])
140 AC_SUBST(GLIB_CFLAGS)
141 AC_SUBST(GLIB_LIBS)
142
143 dnl Check for GStreamer
144 PKG_CHECK_MODULES([GST],
145     [gstreamer-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED]
146 )
147 AC_SUBST(GST_CFLAGS)
148 AC_SUBST(GST_LIBS)
149
150 AC_CACHE_CHECK([for GstBaseSink::query hook], ac_cv_have_gst_base_sink_query, [
151     saved_CFLAGS="$CFLAGS"
152     CFLAGS="$CFLAGS $GST_CFLAGS"
153     saved_LIBS="$LIBS"
154     LIBS="$LIBS $GST_LIBS"
155     AC_TRY_COMPILE(
156         [#include <gst/base/gstbasesink.h>],
157         [GstBaseSinkClass klass; klass.query = NULL;],
158         [ac_cv_have_gst_base_sink_query="yes"],
159         [ac_cv_have_gst_base_sink_query="no"]
160     )
161     CFLAGS="$saved_CFLAGS"
162     LIBS="$saved_LIBS"
163 ])
164 if test "$ac_cv_have_gst_base_sink_query" != "yes"; then
165     AC_MSG_ERROR([GstBaseSink does not contain the 'query' vfunc])
166 fi
167
168 dnl Check for GStreamer plugins-base
169 PKG_CHECK_MODULES([GST_PLUGINS_BASE],
170     [gstreamer-plugins-base-$GST_MAJORMINOR >= $GST_PLUGINS_BASE_VERSION_REQUIRED]
171 )
172 AC_SUBST(GST_PLUGINS_BASE_CFLAGS)
173 AC_SUBST(GST_PLUGINS_BASE_LIBS)
174
175 V=`$PKG_CONFIG --modversion gstreamer-plugins-base-$GST_MAJORMINOR`
176 GST_PLUGINS_BASE_MAJOR_VERSION=`echo "$V" | cut -d'.' -f1`
177 GST_PLUGINS_BASE_MINOR_VERSION=`echo "$V" | cut -d'.' -f2`
178 GST_PLUGINS_BASE_MICRO_VERSION=`echo "$V" | cut -d'.' -f3`
179 AC_SUBST(GST_PLUGINS_BASE_MAJOR_VERSION)
180 AC_SUBST(GST_PLUGINS_BASE_MINOR_VERSION)
181 AC_SUBST(GST_PLUGINS_BASE_MICRO_VERSION)
182
183 dnl Check for GStreamer base
184 PKG_CHECK_MODULES([GST_BASE],
185     [gstreamer-base-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED]
186 )
187 AC_SUBST(GST_BASE_CFLAGS)
188 AC_SUBST(GST_BASE_LIBS)
189
190 dnl Check for GStreamer video
191 PKG_CHECK_MODULES([GST_VIDEO],
192     [gstreamer-video-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED]
193 )
194 AC_SUBST(GST_VIDEO_CFLAGS)
195 AC_SUBST(GST_VIDEO_LIBS)
196
197 AC_CACHE_CHECK([for GstVideoOverlayComposition],
198     ac_cv_have_gst_video_overlay_composition, [
199     saved_CFLAGS="$CFLAGS"
200     CFLAGS="$CFLAGS $GST_CFLAGS"
201     saved_LIBS="$LIBS"
202     LIBS="$LIBS $GST_LIBS"
203     AC_TRY_COMPILE(
204         [#include <gst/video/video-overlay-composition.h>],
205         [GstVideoOverlayComposition *c = gst_video_overlay_composition_new(0);],
206         [ac_cv_have_gst_video_overlay_composition="yes"],
207         [ac_cv_have_gst_video_overlay_composition="no"]
208     )
209     CFLAGS="$saved_CFLAGS"
210     LIBS="$saved_LIBS"
211 ])
212 if test "$ac_cv_have_gst_video_overlay_composition" != "yes"; then
213     AC_MSG_ERROR([GstVideoOverlayComposition is not available])
214 fi
215
216 dnl Check for GStreamer basevideo
217 PKG_CHECK_MODULES([GST_BASEVIDEO],
218     [gstreamer-basevideo-$GST_MAJORMINOR >= $GST_PLUGINS_BAD_VERSION_REQUIRED]
219 )
220 AC_SUBST(GST_BASEVIDEO_CFLAGS)
221 AC_SUBST(GST_BASEVIDEO_LIBS)
222
223 dnl Check for GStreamer interfaces
224 PKG_CHECK_MODULES([GST_INTERFACES],
225     [gstreamer-interfaces-$GST_MAJORMINOR >= $GST_PLUGINS_BASE_VERSION_REQUIRED]
226 )
227 AC_SUBST(GST_INTERFACES_CFLAGS)
228 AC_SUBST(GST_INTERFACES_LIBS)
229
230 dnl GST_ALL_LDFLAGS:
231 dnl LDFLAGS really should only contain flags, not libs - they get added before
232 dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
233 GST_ALL_LDFLAGS="-no-undefined"
234 AC_SUBST(GST_ALL_LDFLAGS)
235
236 dnl GST_PLUGIN_LDFLAGS:
237 dnl this really should only contain flags, not libs - they get added before
238 dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
239 GST_PLUGIN_LDFLAGS="-module -avoid-version -export-symbols-regex '^([_]*gst_plugin_desc|gst_.*_get_type)\$\$' $GST_ALL_LDFLAGS"
240 AC_SUBST(GST_PLUGIN_LDFLAGS)
241
242 dnl Check for the GStreamer plugins directory
243 AC_MSG_CHECKING([for GStreamer plugins directory])
244 GST_PLUGINS_DIR=`$PKG_CONFIG gstreamer-$GST_MAJORMINOR --variable pluginsdir`
245 if test -z "$GST_PLUGINS_DIR"; then
246     echo "FAIL FAIL FAIL"
247     GST_PLUGINS_DIR="\$(libdir)/gstreamer-$GST_MAJORMINOR"
248 fi
249 AC_MSG_RESULT([$GST_PLUGINS_DIR])
250 plugindir="$GST_PLUGINS_DIR"
251 AC_SUBST(plugindir)
252
253 dnl Check for X11
254 PKG_CHECK_MODULES(X11, [x11])
255
256 dnl Check for OpenGL
257 USE_GLX=1
258 if test "$enable_glx" != "yes"; then
259     USE_GLX=0
260 fi
261 GLX_CFLAGS=""
262 GLX_LIBS=""
263 AC_CHECK_HEADERS([GL/gl.h GL/glext.h GL/glx.h], [], [USE_GLX=0], [
264 #ifdef HAVE_GL_GL_H
265 # include <GL/gl.h>
266 #endif
267 ])
268 AC_CHECK_LIB(GL, glXCreateContext, [GLX_LIBS="-lGL"], [USE_GLX=0])
269 AC_SUBST(GLX_CFLAGS)
270 AC_SUBST(GLX_LIBS)
271
272 dnl Check for VA-API
273 LIBVA_PKGNAME="libva"
274 PKG_CHECK_MODULES(LIBVA, [$LIBVA_PKGNAME])
275 AC_SUBST(LIBVA_PKGNAME)
276
277 dnl ... original VA-API 0.29
278 AC_CACHE_CHECK([for old VA-API 0.29],
279     ac_cv_have_vaapi_old, [
280     saved_CFLAGS="$CFLAGS"
281     CFLAGS="$CFLAGS $LIBVA_CFLAGS"
282     saved_LIBS="$LIBS"
283     LIBS="$LIBS $LIBVA_LIBS"
284     AC_TRY_LINK(
285     [#include <va_x11.h>],
286     [vaGetDisplay(NULL)],
287     [ac_cv_have_vaapi_old="yes"],
288     [ac_cv_have_vaapi_old="no"])
289     CFLAGS="$saved_CFLAGS"
290     LIBS="$saved_LIBS"
291 ])
292 if test "$ac_cv_have_vaapi_old" = "yes"; then
293     LIBVA_EXTRA_CFLAGS="$LIBVA_CFLAGS -DGST_VAAPI_USE_OLD_VAAPI_0_29"
294 fi
295
296 dnl ... VA-API >= 0.31 or -sds
297 LIBVA_X11_PKGNAME="libva-x11"
298 PKG_CHECK_MODULES(LIBVA_X11, [$LIBVA_X11_PKGNAME],
299     [ac_cv_have_vaapi_x11="yes"],
300     [ac_cv_have_vaapi_x11="no"]
301 )
302 if test "$ac_cv_have_vaapi_x11" = "no"; then
303     if test "$ac_cv_have_vaapi_old" = "yes"; then
304         LIBVA_X11_PKGNAME="libva"
305         CFLAGS="$CFLAGS $LIBVA_EXTRA_CFLAGS"
306         LIBS="$LIBS $LIBVA_EXTRA_LIBS"
307     else
308         AC_MSG_ERROR([could not find VA-API])
309     fi
310 fi
311 AC_SUBST(LIBVA_X11_PKGNAME)
312
313 dnl ... VA-API >= 0.31 or -sds (VA/GLX extensions)
314 USE_VAAPI_GLX=0
315 if test $USE_GLX -eq 1; then
316     if test "$enable_vaapi_glx" = "yes"; then
317         LIBVA_GLX_PKGNAME="libva-glx"
318         PKG_CHECK_MODULES(LIBVA_GLX, [$LIBVA_GLX_PKGNAME],
319             [ac_cv_have_vaapi_glx="yes" USE_VAAPI_GLX=1],
320             [ac_cv_have_vaapi_glx="no"]
321         )
322     fi
323     if test $USE_VAAPI_GLX -eq 0; then
324         AC_MSG_WARN([VA/GLX not found or disabled. Fallbacking to TFP+FBO])
325         LIBVA_GLX_PKGNAME="$LIBVA_X11_PKGNAME"
326     fi
327 fi
328 AC_SUBST(LIBVA_GLX_PKGNAME)
329
330 AC_SUBST(LIBVA_EXTRA_CFLAGS)
331 AC_SUBST(LIBVA_EXTRA_LIBS)
332
333 dnl Check for OpenGL support to vaapisink
334 if test "$enable_vaapisink_glx:$USE_GLX" = "yes:1"; then
335     USE_VAAPISINK_GLX=1
336 else
337     USE_VAAPISINK_GLX=0
338 fi
339
340 dnl Check for FFmpeg
341 PKG_CHECK_MODULES(LIBAVCODEC, [libavcodec])
342 AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/avcodec.h])
343 AC_CHECK_HEADERS([libavcodec/vaapi.h ffmpeg/vaapi.h], [break],
344     AC_MSG_ERROR([The system FFmpeg headers do not support VA-API]))
345
346 AC_DEFINE_UNQUOTED(USE_GLX, $USE_GLX,
347     [Defined to 1 if GLX is enabled])
348 AM_CONDITIONAL(USE_GLX, test $USE_GLX -eq 1)
349
350 AC_DEFINE_UNQUOTED(USE_VAAPI_GLX, $USE_VAAPI_GLX,
351     [Defined to 1 if VA/GLX is enabled])
352 AM_CONDITIONAL(USE_VAAPI_GLX, test $USE_VAAPI_GLX -eq 1)
353
354 AC_DEFINE_UNQUOTED(USE_VAAPISINK_GLX, $USE_VAAPISINK_GLX,
355     [Defined to 1 to enable GLX support to vaapisink])
356 AM_CONDITIONAL(USE_VAAPISINK_GLX, test $USE_VAAPISINK_GLX -eq 1)
357
358 VA_VERSION=`$PKG_CONFIG --modversion libva`
359 VA_MAJOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f1`
360 VA_MINOR_VERSION=`echo "$VA_VERSION" | cut -d'.' -f2`
361 VA_MICRO_VERSION=`echo "$VA_VERSION" | cut -d'.' -f3`
362 VA_VERSION_STR="$VA_VERSION"
363
364 pkgconfigdir=${libdir}/pkgconfig
365 AC_SUBST(pkgconfigdir)
366
367 AC_OUTPUT([
368     Makefile
369     debian.upstream/Makefile
370     debian.upstream/changelog
371     debian.upstream/control
372     debian.upstream/gstreamer$GST_MAJORMINOR-vaapi.install:\
373 debian.upstream/gstreamer-vaapi.install.in
374     debian.upstream/gstreamer$GST_MAJORMINOR-vaapi-doc.install:\
375 debian.upstream/gstreamer-vaapi-doc.install.in
376     debian.upstream/libgstvaapi$GST_VAAPI_MAJOR_VERSION.install:\
377 debian.upstream/libgstvaapi.install.in
378     debian.upstream/libgstvaapi-dev.install
379     debian.upstream/libgstvaapi-x11-$GST_VAAPI_MAJOR_VERSION.install:\
380 debian.upstream/libgstvaapi-x11.install.in
381     debian.upstream/libgstvaapi-glx-$GST_VAAPI_MAJOR_VERSION.install:\
382 debian.upstream/libgstvaapi-glx.install.in
383     docs/Makefile
384     docs/reference/Makefile
385     docs/reference/libs/Makefile
386     docs/reference/libs/libs-docs.xml
387     docs/reference/plugins/Makefile
388     docs/reference/plugins/plugins-docs.xml
389     gst-libs/Makefile
390     gst-libs/gst/Makefile
391     gst-libs/gst/gstutils_version.h
392     gst-libs/gst/vaapi/Makefile
393     pkgconfig/Makefile
394     pkgconfig/gstreamer-vaapi-$GST_MAJORMINOR.pc:\
395 pkgconfig/gstreamer-vaapi.pc.in
396     pkgconfig/gstreamer-vaapi-glx-$GST_MAJORMINOR.pc:\
397 pkgconfig/gstreamer-vaapi-glx.pc.in
398     pkgconfig/gstreamer-vaapi-x11-$GST_MAJORMINOR.pc:\
399 pkgconfig/gstreamer-vaapi-x11.pc.in
400     gst/Makefile
401     gst/vaapi/Makefile
402     tests/Makefile
403 ])
404
405 dnl Print summary
406 yesno() {
407     test $1 -eq 1 && echo yes || echo no
408 }
409
410 echo
411 echo $PACKAGE configuration summary:
412 echo
413 echo VA-API version ................... : $VA_VERSION_STR
414 echo GLX support ...................... : $(yesno $USE_GLX)
415 echo VA/GLX support ................... : $(yesno $USE_VAAPI_GLX)
416 echo VaapiSink/GL ..................... : $(yesno $USE_VAAPISINK_GLX)
417 echo