xref: /aosp_15_r20/external/libva/configure.ac (revision 54e60f844a168e9a219354de272cd517ee8cd4b7)
1# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
2#
3# Permission is hereby granted, free of charge, to any person obtaining a
4# copy of this software and associated documentation files (the
5# "Software"), to deal in the Software without restriction, including
6# without limitation the rights to use, copy, modify, merge, publish,
7# distribute, sub license, and/or sell copies of the Software, and to
8# permit persons to whom the Software is furnished to do so, subject to
9# the following conditions:
10#
11# The above copyright notice and this permission notice (including the
12# next paragraph) shall be included in all copies or substantial portions
13# of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
18# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
19# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23# VA-API version
24# - increment major for any ABI change
25# - increment minor for any interface change (e.g. new/modified function)
26# - increment micro for any other change (new flag, new codec definition, etc.)
27# - reset micro version to zero when minor version is incremented
28# - reset minor version to zero when major version is incremented
29m4_define([va_api_major_version], [1])
30m4_define([va_api_minor_version], [22])
31m4_define([va_api_micro_version], [0])
32
33m4_define([va_api_version],
34          [va_api_major_version.va_api_minor_version.va_api_micro_version])
35
36# libva package version number, (as distinct from shared library version)
37# XXX: we want the package version to remain at 1.0.x for VA-API 0.32.y
38#
39# - major version is automatically generated from VA-API major version
40# - minor version is automatically generated from VA-API minor version
41# - increment micro for any library release
42# - reset micro version to zero when VA-API major or minor version is changed
43m4_define([libva_major_version], [m4_eval(va_api_major_version + 1)])
44m4_define([libva_minor_version], [m4_eval(va_api_minor_version)])
45m4_define([libva_micro_version], [0])
46m4_define([libva_pre_version],   [0])
47
48m4_define([libva_version],
49          [libva_major_version.libva_minor_version.libva_micro_version])
50m4_if(libva_pre_version, [0], [], [
51m4_append([libva_version], libva_pre_version, [.pre])
52])
53
54# libva library version number (generated, do not change)
55# XXX: we want the SONAME to remain at libva.so.1 for VA-API major == 0
56#
57# The library name is generated libva.<x>.<y>.0 where
58# <x> = VA-API major version + 1
59# <y> = 100 * VA-API minor version + VA-API micro version
60#
61# For example:
62# VA-API 0.32.0 generates libva.so.1.3200.0
63# VA-API 0.34.1 generates libva.so.1.3401.0
64# VA-API 1.2.13 generates libva.so.2.213.0
65m4_define([libva_interface_bias], [m4_eval(va_api_major_version + 1)])
66m4_define([libva_interface_age],  [0])
67m4_define([libva_binary_age],
68          [m4_eval(100 * va_api_minor_version + va_api_micro_version - libva_interface_age)])
69
70m4_define([libva_lt_current],
71          [m4_eval(100 * va_api_minor_version + va_api_micro_version + libva_interface_bias)])
72m4_define([libva_lt_revision],
73          [m4_eval(libva_interface_age)])
74m4_define([libva_lt_age],
75          [m4_eval(libva_binary_age - libva_interface_age)])
76
77# libdrm minimun version requirement
78# 2.4.75 for drmGetDevices2
79m4_define([libdrm_version], [2.4.75])
80
81# Wayland minimum version number
82# 1.11.0 for wl_proxy_create_wrapper
83m4_define([wayland_api_version], [1.11.0])
84
85AC_PREREQ(2.57)
86AC_INIT([libva],
87        [libva_version],
88        [https://github.com/intel/libva/issues/new],
89        [libva],
90        [https://github.com/intel/libva])
91
92AC_CONFIG_SRCDIR([Makefile.am])
93AC_CONFIG_MACRO_DIR([m4])
94AM_INIT_AUTOMAKE([dist-bzip2 -Wno-portability])
95
96AC_CONFIG_HEADERS([config.h])
97m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
98
99TODAY="`LC_ALL=C date +'%a, %d %b %Y %X %z'`"
100AC_SUBST(TODAY)
101
102VA_API_MAJOR_VERSION=va_api_major_version
103VA_API_MINOR_VERSION=va_api_minor_version
104VA_API_MICRO_VERSION=va_api_micro_version
105VA_API_VERSION=va_api_version
106AC_SUBST(VA_API_MAJOR_VERSION)
107AC_SUBST(VA_API_MINOR_VERSION)
108AC_SUBST(VA_API_MICRO_VERSION)
109AC_SUBST(VA_API_VERSION)
110
111LIBVA_MAJOR_VERSION=libva_major_version
112LIBVA_MINOR_VERSION=libva_minor_version
113LIBVA_MICRO_VERSION=libva_micro_version
114LIBVA_VERSION=libva_version
115AC_SUBST(LIBVA_MAJOR_VERSION)
116AC_SUBST(LIBVA_MINOR_VERSION)
117AC_SUBST(LIBVA_MICRO_VERSION)
118AC_SUBST(LIBVA_VERSION)
119
120LIBVA_LT_CURRENT=libva_lt_current
121LIBVA_LT_REV=libva_lt_revision
122LIBVA_LT_AGE=libva_lt_age
123LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE"
124LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION"
125AC_SUBST(LIBVA_LT_VERSION)
126AC_SUBST(LIBVA_LT_LDFLAGS)
127
128AC_ARG_ENABLE(docs,
129    [AC_HELP_STRING([--enable-docs],
130                    [build Doxygen documentation @<:@default=no@:>@])],
131    [], [enable_docs="no"])
132
133AC_ARG_ENABLE(drm,
134    [AC_HELP_STRING([--enable-drm],
135                    [build with VA/DRM API support @<:@default=yes@:>@])],
136    [], [enable_drm="yes"])
137
138AC_ARG_ENABLE(x11,
139    [AC_HELP_STRING([--enable-x11],
140                    [build with VA/X11 API support @<:@default=auto@:>@])],
141    [], [enable_x11="auto"])
142
143AC_ARG_ENABLE(glx,
144    [AC_HELP_STRING([--enable-glx],
145                    [build with VA/GLX API support @<:@default=auto@:>@])],
146    [], [enable_glx="auto"])
147
148AC_ARG_ENABLE([wayland],
149    [AC_HELP_STRING([--enable-wayland],
150                    [build with VA/Wayland API support @<:@default=auto@:>@])],
151    [], [enable_wayland="auto"])
152
153AC_ARG_WITH(legacy,
154    [AC_HELP_STRING([--with-legacy=[[components]]],
155                    [build with legacy components @<:@default=emgd,nvctrl,fglrx@:>@])],
156    [], [with_legacy="emgd,nvctrl,fglrx"])
157
158if test "$with_legacy" = *emgd*; then
159    AC_DEFINE([HAVE_EMGD], [1], [Defined to 1 if EMGD is built])
160fi
161if test "$with_legacy" = *nvctrl*; then
162    AC_DEFINE([HAVE_NVCTRL], [1], [Defined to 1 if NVCTRL is built])
163fi
164if test "$with_legacy" = *fglrx*; then
165    AC_DEFINE([HAVE_FGLRX], [1], [Defined to 1 if FGLRX is built])
166fi
167
168AC_ARG_WITH(drivers-path,
169    [AC_HELP_STRING([--with-drivers-path=[[path]]],
170                    [drivers path])],
171    [], [with_drivers_path="$libdir/dri"])
172
173LIBVA_DRIVERS_PATH="$with_drivers_path"
174AC_SUBST(LIBVA_DRIVERS_PATH)
175
176AC_DISABLE_STATIC
177AC_PROG_LIBTOOL
178AC_PROG_CC
179AC_PROG_CXX
180AM_PROG_CC_C_O
181AC_PROG_SED
182PKG_PROG_PKG_CONFIG
183
184AC_HEADER_STDC
185AC_SYS_LARGEFILE
186
187#check for secure_getenv
188AC_CHECK_FUNCS(secure_getenv)
189
190# Check for Doxygen
191if test "$enable_docs" = "yes"; then
192    AC_CHECK_TOOL([DOXYGEN], [doxygen], [no])
193    if test "$DOXYGEN" = "no"; then
194       enable_docs="no"
195    fi
196fi
197AM_CONDITIONAL(ENABLE_DOCS, test "$enable_docs" = "yes")
198
199# Check for -ldl (often not required)
200AC_SEARCH_LIBS([dlopen], [dl], [], [
201  AC_MSG_ERROR([unable to find the dlopen() function])
202])
203
204# Check for -fstack-protector and -fstack-protector-strong
205SSP_CC_FLAG=""
206if test "X$CC-cc" != "X"; then
207    # Do not duplicate options in CFLAGS
208    ssp_sp_set=no
209    ssp_sps_set=no
210    for ssp_x in $CFLAGS; do
211        case "X$ssp_x" in
212            X-fstack-protector) ssp_sp_set=yes ;;
213            X-fstack-protector-strong) ssp_sps_set=yes ;;
214        esac
215    done
216    ssp_old_cflags="$CFLAGS"
217    # Prefer -fstack-protector-strong over -fstack-protector
218    if test "X$ssp_sps_set" = "Xno"; then
219        SSP_CC_FLAG="-fstack-protector-strong"
220    fi
221    AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector-strong])
222    CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
223    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [ssp_cc=yes], [ssp_cc=no])
224    AC_MSG_RESULT([$ssp_cc])
225    if test "X$ssp_cc" = "Xno"; then
226        # Fallback to -fstack-protector
227        if test "X$ssp_sp_set" = "Xno"; then
228            SSP_CC_FLAG="-fstack-protector"
229        fi
230        AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector])
231        CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
232        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [ssp_cc=yes], [ssp_cc=no])
233        AC_MSG_RESULT([$ssp_cc])
234        if test "X$ssp_cc" = "Xno"; then
235            SSP_CC_FLAG=""
236        fi
237    fi
238    CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
239    if test "X$ssp_cc" = "Xyes"; then
240        AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
241    fi
242fi
243AC_SUBST(SSP_CC_FLAG)
244
245# Check for DRM (mandatory)
246LIBDRM_VERSION=libdrm_version
247PKG_CHECK_MODULES([DRM], [libdrm >= $LIBDRM_VERSION])
248AC_SUBST(LIBDRM_VERSION)
249
250USE_DRM="no"
251if test "$enable_drm" = "yes"; then
252    USE_DRM="yes"
253    AC_DEFINE([HAVE_VA_DRM], [1], [Defined to 1 if VA/DRM API is built])
254fi
255AM_CONDITIONAL(USE_DRM, test "$USE_DRM" = "yes")
256
257# Check for X11
258USE_X11="no"
259if test "x$enable_x11" != "xno"; then
260    PKG_CHECK_MODULES([X11],    [x11 xext xfixes x11-xcb xcb xcb-dri3],    [USE_X11="yes"], [:])
261
262    if test "x$USE_X11" = "xno" -a "x$enable_x11" = "xyes"; then
263       AC_MSG_ERROR([VA/X11 explicitly enabled, however $X11_PKG_ERRORS])
264    fi
265
266    if test "$USE_X11" = "yes"; then
267        AC_DEFINE([HAVE_VA_X11], [1], [Defined to 1 if VA/X11 API is built])
268    fi
269fi
270AM_CONDITIONAL(USE_X11, test "$USE_X11" = "yes")
271
272# Check for GLX
273USE_GLX="no"
274
275if test "$USE_X11:$enable_glx" = "no:yes"; then
276   AC_MSG_ERROR([VA/GLX explicitly enabled, but VA/X11 isn't built])
277fi
278
279if test "$USE_X11" = "yes" -a "$enable_glx" != "no"; then
280    PKG_CHECK_MODULES([GLX], [gl x11], [USE_GLX="yes"], [:])
281    saved_CPPFLAGS="$CPPFLAGS"
282    saved_LIBS="$LIBS"
283    CPPFLAGS="$CPPFLAGS $GLX_CFLAGS"
284    LIBS="$LIBS $GLX_LIBS"
285    AC_CHECK_HEADERS([GL/gl.h GL/glx.h], [:], [USE_GLX="no"])
286    AC_CHECK_LIB([GL], [glXCreateContext], [:] [USE_GLX="no"])
287    CPPFLAGS="$saved_CPPFLAGS"
288    LIBS="$saved_LIBS"
289
290    if test "x$USE_GLX" = "xno" -a "x$enable_glx" = "xyes"; then
291       AC_MSG_ERROR([VA/GLX explicitly enabled, but libGL couldn't be found])
292    fi
293
294    if test "$USE_GLX" = "yes"; then
295        AC_DEFINE([HAVE_VA_GLX], [1], [Defined to 1 if VA/GLX API is built])
296    fi
297fi
298AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes")
299
300# Check for Wayland
301WAYLAND_API_VERSION=wayland_api_version
302AC_SUBST(WAYLAND_API_VERSION)
303
304USE_WAYLAND="no"
305if test "x$enable_wayland" != "xno"; then
306    PKG_CHECK_MODULES([WAYLAND], [wayland-client >= wayland_api_version],
307        [USE_WAYLAND="yes"], [:])
308
309    if test "x$USE_WAYLAND" = "xno" -a "x$enable_wayland" = "xyes"; then
310        AC_MSG_ERROR([wayland explicitly enabled, however $WAYLAND_PKG_ERRORS])
311    fi
312
313    if test "$USE_WAYLAND" = "yes"; then
314
315        AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner])
316        if test "x$WAYLAND_SCANNER" = "x"; then
317            PKG_CHECK_MODULES([WL_SCANNER], [wayland-scanner >= 1.15],
318                [USE_WAYLAND="yes"], [:])
319
320            if test "x$USE_WAYLAND" = "xno" -a "x$enable_wayland" = "xyes"; then
321                AC_MSG_ERROR([wayland explicitly enabled, however $WL_SCANNER_PKG_ERRORS])
322            fi
323            AC_SUBST(WAYLAND_SCANNER, `$PKG_CONFIG --variable=wayland_scanner wayland-scanner`)
324        fi
325
326        AC_DEFINE([HAVE_VA_WAYLAND], [1],
327                  [Defined to 1 if VA/Wayland API is built])
328    fi
329fi
330
331AM_CONDITIONAL(USE_WAYLAND, test "$USE_WAYLAND" = "yes")
332
333pkgconfigdir=${libdir}/pkgconfig
334AC_SUBST(pkgconfigdir)
335
336# Check for builds without backend
337if test "$USE_DRM:$USE_X11:$USE_WAYLAND" = "no:no:no"; then
338    AC_MSG_ERROR([Please select at least one backend (DRM, X11, Wayland)])
339fi
340
341AC_OUTPUT([
342    Makefile
343    doc/Makefile
344    pkgconfig/Makefile
345    pkgconfig/libva-drm.pc
346    pkgconfig/libva-glx.pc
347    pkgconfig/libva-wayland.pc
348    pkgconfig/libva-x11.pc
349    pkgconfig/libva.pc
350    va/Makefile
351    va/drm/Makefile
352    va/glx/Makefile
353    va/va_version.h
354    va/wayland/Makefile
355    va/x11/Makefile
356])
357
358# Print a small summary
359BACKENDS=""
360AS_IF([test x$USE_DRM = xyes], [BACKENDS="$BACKENDS drm"])
361AS_IF([test x$USE_X11 = xyes], [BACKENDS="$BACKENDS x11"])
362AS_IF([test x$USE_GLX = xyes], [BACKENDS="$BACKENDS glx"])
363AS_IF([test x$USE_WAYLAND = xyes], [BACKENDS="$BACKENDS wayland"])
364
365echo
366echo "libva - ${LIBVA_VERSION} (VA-API ${VA_API_VERSION})"
367echo
368echo Installation prefix .............. : $prefix
369echo Default driver path .............. : $LIBVA_DRIVERS_PATH
370echo Extra window systems ............. : $BACKENDS
371echo Build with legacy ................ : $with_legacy
372echo Build documentation .............. : $enable_docs
373echo
374