configure 218 KB
Newer Older
1
#!/bin/sh
2
#
3
# FFmpeg configure script
4
#
Diego Biurrun's avatar
Diego Biurrun committed
5 6 7
# Copyright (c) 2000-2002 Fabrice Bellard
# Copyright (c) 2005-2008 Diego Biurrun
# Copyright (c) 2005-2008 Mans Rullgard
8
#
9

10
# Prevent locale nonsense from breaking basic text processing.
11 12
LC_ALL=C
export LC_ALL
13

14
# make sure we are running under a compatible shell
15 16 17
# try to make this part work with most shells

try_exec(){
18
    echo "Trying shell $1"
19
    type "$1" > /dev/null 2>&1 && exec "$@"
20 21
}

22
unset foo
23
(: ${foo%%bar}) 2> /dev/null
24 25
E1="$?"

26
(: ${foo?}) 2> /dev/null
27 28 29 30
E2="$?"

if test "$E1" != 0 || test "$E2" = 0; then
    echo "Broken shell detected.  Trying alternatives."
31 32 33 34 35 36 37 38 39 40 41 42
    export FF_CONF_EXEC
    if test "0$FF_CONF_EXEC" -lt 1; then
        FF_CONF_EXEC=1
        try_exec bash "$0" "$@"
    fi
    if test "0$FF_CONF_EXEC" -lt 2; then
        FF_CONF_EXEC=2
        try_exec ksh "$0" "$@"
    fi
    if test "0$FF_CONF_EXEC" -lt 3; then
        FF_CONF_EXEC=3
        try_exec /usr/xpg4/bin/sh "$0" "$@"
43 44
    fi
    echo "No compatible shell script interpreter found."
Diego Biurrun's avatar
Diego Biurrun committed
45
    echo "This configure script requires a POSIX-compatible shell"
46
    echo "such as bash or ksh."
47
    echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
48
    echo "Instead, install a working POSIX-compatible shell."
49
    echo "Disabling this configure test will create a broken FFmpeg."
50 51 52 53
    if test "$BASH_VERSION" = '2.04.0(1)-release'; then
        echo "This bash version ($BASH_VERSION) is broken on your platform."
        echo "Upgrade to a later version if available."
    fi
54 55 56
    exit 1
fi

57 58
test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH

59
show_help(){
60
    cat <<EOF
61 62 63
Usage: configure [options]
Options: [defaults in brackets after descriptions]

64
Help options:
65
  --help                   print this message
66 67 68 69 70 71 72 73 74 75 76 77 78
  --list-decoders          show all available decoders
  --list-encoders          show all available encoders
  --list-hwaccels          show all available hardware accelerators
  --list-demuxers          show all available demuxers
  --list-muxers            show all available muxers
  --list-parsers           show all available parsers
  --list-protocols         show all available protocols
  --list-bsfs              show all available bitstream filters
  --list-indevs            show all available input devices
  --list-outdevs           show all available output devices
  --list-filters           show all available filters

Standard options:
79
  --logfile=FILE           log tests and output to FILE [config.log]
80
  --disable-logging        do not log configure debug information
81
  --fatal-warnings         fail if any configure warning is generated
82 83
  --prefix=PREFIX          install in PREFIX [$prefix]
  --bindir=DIR             install binaries in DIR [PREFIX/bin]
84
  --datadir=DIR            install data files in DIR [PREFIX/share/ffmpeg]
85
  --docdir=DIR             install documentation in DIR [PREFIX/share/doc/ffmpeg]
86
  --libdir=DIR             install libs in DIR [PREFIX/lib]
87
  --shlibdir=DIR           install shared libs in DIR [LIBDIR]
88 89
  --incdir=DIR             install includes in DIR [PREFIX/include]
  --mandir=DIR             install man page in DIR [PREFIX/share/man]
90
  --pkgconfigdir=DIR       install pkg-config files in DIR [LIBDIR/pkgconfig]
91 92
  --enable-rpath           use rpath to allow installing libraries in paths
                           not part of the dynamic linker search path
93
                           use rpath when linking programs [USE WITH CARE]
94
  --install-name-dir=DIR   Darwin directory name for installed targets
95

96
Licensing options:
97 98 99 100 101
  --enable-gpl             allow use of GPL code, the resulting libs
                           and binaries will be under GPL [no]
  --enable-version3        upgrade (L)GPL to version 3 [no]
  --enable-nonfree         allow use of nonfree code, the resulting libs
                           and binaries will be unredistributable [no]
102 103 104 105 106

Configuration options:
  --disable-static         do not build static libraries [no]
  --enable-shared          build shared libraries [no]
  --enable-small           optimize for size instead of speed
107
  --disable-runtime-cpudetect disable detecting cpu capabilities at runtime (smaller binary)
108 109
  --enable-gray            enable full grayscale support (slower color)
  --disable-swscale-alpha  disable alpha channel support in swscale
110
  --disable-all            disable building components, libraries and programs
111
  --enable-incompatible-libav-abi enable incompatible Libav fork ABI [no]
112
  --enable-raise-major     increase major version numbers in sonames [no]
113

114 115
Program options:
  --disable-programs       do not build command line programs
116 117 118 119
  --disable-ffmpeg         disable ffmpeg build
  --disable-ffplay         disable ffplay build
  --disable-ffprobe        disable ffprobe build
  --disable-ffserver       disable ffserver build
120

121
Documentation options:
122
  --disable-doc            do not build documentation
123 124 125 126 127 128
  --disable-htmlpages      do not build HTML documentation pages
  --disable-manpages       do not build man documentation pages
  --disable-podpages       do not build POD documentation pages
  --disable-txtpages       do not build text documentation pages

Component options:
129 130 131
  --disable-avdevice       disable libavdevice build
  --disable-avcodec        disable libavcodec build
  --disable-avformat       disable libavformat build
Michael Niedermayer's avatar
Michael Niedermayer committed
132
  --disable-swresample     disable libswresample build
133
  --disable-swscale        disable libswscale build
134
  --disable-postproc       disable libpostproc build
135
  --disable-avfilter       disable libavfilter build
136
  --enable-avresample      enable libavresample build [no]
137 138 139
  --disable-pthreads       disable pthreads [autodetect]
  --disable-w32threads     disable Win32 threads [autodetect]
  --disable-os2threads     disable OS/2 threads [autodetect]
140
  --disable-network        disable network support [no]
141
  --disable-dct            disable DCT code
142
  --disable-dwt            disable DWT code
143
  --disable-error-resilience disable error resilience code
144
  --disable-lsp            disable LSP code
145
  --disable-lzo            disable LZO decoder code
146 147
  --disable-mdct           disable MDCT code
  --disable-rdft           disable RDFT code
148
  --disable-fft            disable FFT code
149
  --disable-faan           disable floating point AAN (I)DCT code
150
  --disable-pixelutils     disable pixel utils in libavutil
151

152
Individual component options:
153
  --disable-everything     disable all components listed below
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
  --disable-encoder=NAME   disable encoder NAME
  --enable-encoder=NAME    enable encoder NAME
  --disable-encoders       disable all encoders
  --disable-decoder=NAME   disable decoder NAME
  --enable-decoder=NAME    enable decoder NAME
  --disable-decoders       disable all decoders
  --disable-hwaccel=NAME   disable hwaccel NAME
  --enable-hwaccel=NAME    enable hwaccel NAME
  --disable-hwaccels       disable all hwaccels
  --disable-muxer=NAME     disable muxer NAME
  --enable-muxer=NAME      enable muxer NAME
  --disable-muxers         disable all muxers
  --disable-demuxer=NAME   disable demuxer NAME
  --enable-demuxer=NAME    enable demuxer NAME
  --disable-demuxers       disable all demuxers
  --enable-parser=NAME     enable parser NAME
  --disable-parser=NAME    disable parser NAME
  --disable-parsers        disable all parsers
  --enable-bsf=NAME        enable bitstream filter NAME
  --disable-bsf=NAME       disable bitstream filter NAME
  --disable-bsfs           disable all bitstream filters
  --enable-protocol=NAME   enable protocol NAME
  --disable-protocol=NAME  disable protocol NAME
  --disable-protocols      disable all protocols
178
  --enable-indev=NAME      enable input device NAME
179 180
  --disable-indev=NAME     disable input device NAME
  --disable-indevs         disable input devices
181 182
  --enable-outdev=NAME     enable output device NAME
  --disable-outdev=NAME    disable output device NAME
183 184 185 186 187 188 189
  --disable-outdevs        disable output devices
  --disable-devices        disable all devices
  --enable-filter=NAME     enable filter NAME
  --disable-filter=NAME    disable filter NAME
  --disable-filters        disable all filters

External library support:
190

191
  Using any of the following switches will allow FFmpeg to link to the
192 193 194 195 196 197 198 199 200 201
  corresponding external library. All the components depending on that library
  will become enabled, if all their other dependencies are met and they are not
  explicitly disabled. E.g. --enable-libwavpack will enable linking to
  libwavpack and allow the libwavpack encoder to be built, unless it is
  specifically disabled with --disable-encoder=libwavpack.

  Note that only the system libraries are auto-detected. All the other external
  libraries must be explicitly enabled.

  Also note that the following help text describes the purpose of the libraries
202 203
  themselves, not all their features will necessarily be usable by FFmpeg.

Diego Biurrun's avatar
Diego Biurrun committed
204
  --enable-avisynth        enable reading of AviSynth script files [no]
205
  --disable-bzlib          disable bzlib [autodetect]
206
  --enable-chromaprint     enable audio fingerprinting with chromaprint [no]
207
  --enable-frei0r          enable frei0r video filtering [no]
208 209 210 211
  --enable-gcrypt          enable gcrypt, needed for rtmp(t)e support
                           if openssl, librtmp or gmp is not used [no]
  --enable-gmp             enable gmp, needed for rtmp(t)e support
                           if openssl or librtmp is not used [no]
212 213
  --enable-gnutls          enable gnutls, needed for https support
                           if openssl is not used [no]
214
  --disable-iconv          disable iconv [autodetect]
Matthieu Bouron's avatar
Matthieu Bouron committed
215
  --enable-jni             enable JNI support [no]
216 217 218
  --enable-ladspa          enable LADSPA audio filtering [no]
  --enable-libass          enable libass subtitles rendering,
                           needed for subtitles and ass filter [no]
Petri Hintukainen's avatar
Petri Hintukainen committed
219
  --enable-libbluray       enable BluRay reading using libbluray [no]
220
  --enable-libbs2b         enable bs2b DSP library [no]
221
  --enable-libcaca         enable textual display using libcaca [no]
222
  --enable-libcelt         enable CELT decoding via libcelt [no]
223
  --enable-libcdio         enable audio CD grabbing with libcdio [no]
224 225
  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
                           and libraw1394 [no]
Kyle Swanson's avatar
Kyle Swanson committed
226 227
  --enable-libebur128      enable libebur128 for EBU R128 measurement,
                           needed for loudnorm filter [no]
228
  --enable-libfaac         enable AAC encoding via libfaac [no]
229
  --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
230
  --enable-libflite        enable flite (voice synthesis) support via libflite [no]
231
  --enable-libfontconfig   enable libfontconfig, useful for drawtext filter [no]
232 233
  --enable-libfreetype     enable libfreetype, needed for drawtext filter [no]
  --enable-libfribidi      enable libfribidi, improves drawtext filter [no]
wm4's avatar
wm4 committed
234
  --enable-libgme          enable Game Music Emu via libgme [no]
235
  --enable-libgsm          enable GSM de/encoding via libgsm [no]
236
  --enable-libiec61883     enable iec61883 via libiec61883 [no]
237
  --enable-libilbc         enable iLBC de/encoding via libilbc [no]
238
  --enable-libkvazaar      enable HEVC encoding via libkvazaar [no]
239
  --enable-libmodplug      enable ModPlug via libmodplug [no]
240 241 242
  --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
  --enable-libnut          enable NUT (de)muxing via libnut,
                           native (de)muxer exists [no]
243 244 245
  --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  --enable-libopencv       enable video filtering via libopencv [no]
246
  --enable-libopenh264     enable H.264 encoding via OpenH264 [no]
247
  --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
248
  --enable-libopus         enable Opus de/encoding via libopus [no]
249
  --enable-libpulse        enable Pulseaudio input via libpulse [no]
250
  --enable-librubberband   enable rubberband needed for rubberband filter [no]
251
  --enable-librtmp         enable RTMP[E] support via librtmp [no]
252
  --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
253
  --enable-libshine        enable fixed-point MP3 encoding via libshine [no]
254
  --enable-libsmbclient    enable Samba protocol via libsmbclient [no]
255
  --enable-libsnappy       enable Snappy compression, needed for hap encoding [no]
256
  --enable-libsoxr         enable Include libsoxr resampling [no]
257
  --enable-libspeex        enable Speex de/encoding via libspeex [no]
258
  --enable-libssh          enable SFTP protocol via libssh [no]
Paul B Mahol's avatar
Paul B Mahol committed
259
  --enable-libtesseract    enable Tesseract, needed for ocr filter [no]
260
  --enable-libtheora       enable Theora encoding via libtheora [no]
261
  --enable-libtwolame      enable MP2 encoding via libtwolame [no]
262
  --enable-libv4l2         enable libv4l2/v4l-utils [no]
263
  --enable-libvidstab      enable video stabilization using vid.stab [no]
264
  --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
265
  --enable-libvorbis       enable Vorbis en/decoding via libvorbis,
266
                           native implementation exists [no]
267
  --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
268
  --enable-libwavpack      enable wavpack encoding via libwavpack [no]
Justin Ruggles's avatar
Justin Ruggles committed
269
  --enable-libwebp         enable WebP encoding via libwebp [no]
270
  --enable-libx264         enable H.264 encoding via x264 [no]
Derek Buitenhuis's avatar
Derek Buitenhuis committed
271
  --enable-libx265         enable HEVC encoding via x265 [no]
272
  --enable-libxavs         enable AVS encoding via xavs [no]
273 274 275 276
  --enable-libxcb          enable X11 grabbing using XCB [autodetect]
  --enable-libxcb-shm      enable X11 grabbing shm communication [autodetect]
  --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
  --enable-libxcb-shape    enable X11 grabbing shape rendering [autodetect]
277 278
  --enable-libxvid         enable Xvid encoding via xvidcore,
                           native MPEG-4/Xvid encoder exists [no]
279
  --enable-libzimg         enable z.lib, needed for zscale filter [no]
280
  --enable-libzmq          enable message passing via libzmq [no]
281
  --enable-libzvbi         enable teletext support via libzvbi [no]
282
  --disable-lzma           disable lzma [autodetect]
283
  --enable-decklink        enable Blackmagic DeckLink I/O support [no]
284
  --enable-mediacodec      enable Android MediaCodec support [no]
285
  --enable-netcdf          enable NetCDF, needed for sofalizer filter [no]
286
  --enable-openal          enable OpenAL 1.1 capture support [no]
287
  --enable-opencl          enable OpenCL code
Lukasz Marek's avatar
Lukasz Marek committed
288
  --enable-opengl          enable OpenGL rendering [no]
289 290
  --enable-openssl         enable openssl, needed for https support
                           if gnutls is not used [no]
291 292
  --disable-schannel       disable SChannel SSP, needed for TLS support on
                           Windows if openssl and gnutls are not used [autodetect]
293
  --disable-sdl            disable sdl [autodetect]
294 295
  --disable-securetransport disable Secure Transport, needed for TLS support
                           on OSX if openssl and gnutls are not used [autodetect]
296
  --enable-x11grab         enable X11 grabbing (legacy) [no]
297
  --disable-xlib           disable xlib [autodetect]
298
  --disable-zlib           disable zlib [autodetect]
299

300
  The following libraries provide various hardware acceleration features:
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
  --disable-audiotoolbox   disable Apple AudioToolbox code [autodetect]
  --enable-cuda            enable dynamically linked Nvidia CUDA code [no]
  --enable-cuvid           enable Nvidia CUVID support [autodetect]
  --disable-d3d11va        disable Microsoft Direct3D 11 video acceleration code [autodetect]
  --disable-dxva2          disable Microsoft DirectX 9 video acceleration code [autodetect]
  --enable-libmfx          enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no]
  --enable-libnpp          enable Nvidia Performance Primitives-based code [no]
  --enable-mmal            enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no]
  --enable-nvenc           enable Nvidia video encoding code [no]
  --enable-omx             enable OpenMAX IL code [no]
  --enable-omx-rpi         enable OpenMAX IL code for Raspberry Pi [no]
  --disable-vaapi          disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
  --disable-vda            disable Apple Video Decode Acceleration code [autodetect]
  --disable-vdpau          disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
  --disable-videotoolbox   disable VideoToolbox code [autodetect]
316

317 318 319 320
Toolchain options:
  --arch=ARCH              select architecture [$arch]
  --cpu=CPU                select the minimum required CPU (affects
                           instruction selection, may crash on older CPUs)
321
  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
322
  --progs-suffix=SUFFIX    program name suffix []
323 324 325 326 327 328
  --enable-cross-compile   assume a cross-compiler is used
  --sysroot=PATH           root of cross-build tree
  --sysinclude=PATH        location of cross-build system headers
  --target-os=OS           compiler targets OS [$target_os]
  --target-exec=CMD        command to run executables on target
  --target-path=DIR        path to view of build directory on target
329
  --target-samples=DIR     path to samples directory on target
330
  --tempprefix=PATH        force fixed dir/prefix instead of mktemp for checks
331
  --toolchain=NAME         set tool defaults according to NAME
332
  --nm=NM                  use nm tool NM [$nm_default]
333
  --ar=AR                  use archive tool AR [$ar_default]
334
  --as=AS                  use assembler AS [$as_default]
335
  --ln_s=LN_S              use symbolic link tool LN_S [$ln_s_default]
336
  --strip=STRIP            use strip tool STRIP [$strip_default]
337
  --windres=WINDRES        use windows resource compiler WINDRES [$windres_default]
338
  --yasmexe=EXE            use yasm-compatible assembler EXE [$yasmexe_default]
339
  --cc=CC                  use C compiler CC [$cc_default]
Mohamed Naufal's avatar
Mohamed Naufal committed
340
  --cxx=CXX                use C compiler CXX [$cxx_default]
Luca Barbato's avatar
Luca Barbato committed
341
  --objcc=OCC              use ObjC compiler OCC [$cc_default]
342
  --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
343
  --ld=LD                  use linker LD [$ld_default]
344
  --pkg-config=PKGCONFIG   use pkg-config tool PKGCONFIG [$pkg_config_default]
345
  --pkg-config-flags=FLAGS pass additional flags to pkgconf []
346
  --ranlib=RANLIB          use ranlib RANLIB [$ranlib_default]
347
  --doxygen=DOXYGEN        use DOXYGEN to generate API doc [$doxygen_default]
348 349
  --host-cc=HOSTCC         use host C compiler HOSTCC
  --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
350
  --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
351
  --host-ld=HOSTLD         use host linker HOSTLD
352 353
  --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
  --host-libs=HLIBS        use libs HLIBS when linking for host
354
  --host-os=OS             compiler host OS [$target_os]
355
  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
Mohamed Naufal's avatar
Mohamed Naufal committed
356
  --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS [$CXXFLAGS]
Luca Barbato's avatar
Luca Barbato committed
357
  --extra-objcflags=FLAGS  add FLAGS to OBJCFLAGS [$CFLAGS]
358
  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
359
  --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
360
  --extra-ldlibflags=ELDFLAGS add ELDFLAGS to LDLIBFLAGS [$LDLIBFLAGS]
361 362
  --extra-libs=ELIBS       add ELIBS [$ELIBS]
  --extra-version=STRING   version string suffix []
363
  --optflags=OPTFLAGS      override optimization-related compiler flags
364
  --build-suffix=SUFFIX    library name suffix []
365
  --enable-pic             build position-independent code
366
  --enable-thumb           compile for Thumb instruction set
367
  --enable-lto             use link-time optimization
368
  --env="ENV=override"     override the environment variables
369 370 371

Advanced options (experts only):
  --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
372
  --custom-allocator=NAME  use a supported custom allocator
373 374 375 376 377 378
  --disable-symver         disable symbol versioning
  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  --disable-safe-bitstream-reader
                           disable buffer boundary checking in bitreaders
                           (faster, but may crash)
  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
379
  --sws-max-filter-size=N  the max filter size swscale uses [$sws_max_filter_size_default]
380 381

Optimization options (experts only):
382
  --disable-asm            disable all assembly optimizations
383
  --disable-altivec        disable AltiVec optimizations
384 385
  --disable-vsx            disable VSX optimizations
  --disable-power8         disable POWER8 optimizations
386 387 388
  --disable-amd3dnow       disable 3DNow! optimizations
  --disable-amd3dnowext    disable 3DNow! extended optimizations
  --disable-mmx            disable MMX optimizations
389
  --disable-mmxext         disable MMXEXT optimizations
390
  --disable-sse            disable SSE optimizations
391 392
  --disable-sse2           disable SSE2 optimizations
  --disable-sse3           disable SSE3 optimizations
393
  --disable-ssse3          disable SSSE3 optimizations
394 395
  --disable-sse4           disable SSE4 optimizations
  --disable-sse42          disable SSE4.2 optimizations
396
  --disable-avx            disable AVX optimizations
397
  --disable-xop            disable XOP optimizations
398
  --disable-fma3           disable FMA3 optimizations
399
  --disable-fma4           disable FMA4 optimizations
400
  --disable-avx2           disable AVX2 optimizations
Rodger Combs's avatar
Rodger Combs committed
401
  --disable-aesni          disable AESNI optimizations
402 403 404
  --disable-armv5te        disable armv5te optimizations
  --disable-armv6          disable armv6 optimizations
  --disable-armv6t2        disable armv6t2 optimizations
405
  --disable-vfp            disable VFP optimizations
406
  --disable-neon           disable NEON optimizations
407 408
  --disable-inline-asm     disable use of inline assembly
  --disable-yasm           disable use of nasm/yasm assembly
409
  --disable-mipsdsp        disable MIPS DSP ASE R1 optimizations
410
  --disable-mipsdspr2      disable MIPS DSP ASE R2 optimizations
411
  --disable-msa            disable MSA optimizations
412
  --disable-mipsfpu        disable floating point MIPS optimizations
413
  --disable-mmi            disable Loongson SIMD optimizations
414
  --disable-fast-unaligned consider unaligned accesses slow
415

416
Developer options (useful when working on FFmpeg itself):
417 418 419 420
  --disable-debug          disable debugging symbols
  --enable-debug=LEVEL     set the debug level [$debuglevel]
  --disable-optimizations  disable compiler optimizations
  --enable-extra-warnings  enable more compiler warnings
421
  --disable-stripping      disable stripping of executables and shared libraries
422
  --assert-level=level     0(default), 1 or 2, amount of assertion testing,
423
                           2 causes a slowdown at runtime.
424
  --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
425 426 427
  --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
                           leaks and errors, using the specified valgrind binary.
                           Cannot be combined with --target-exec
428
  --enable-ftrapv          Trap arithmetic overflows
429 430
  --samples=PATH           location of test samples for FATE, if not set use
                           \$FATE_SAMPLES at make invocation time.
431 432
  --enable-neon-clobber-test check NEON registers for clobbering (should be
                           used only for debugging purposes)
433 434
  --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
                           should be used only for debugging purposes)
435 436 437 438 439 440 441 442
  --enable-random          randomly enable/disable components
  --disable-random
  --enable-random=LIST     randomly enable/disable specific components or
  --disable-random=LIST    component groups. LIST is a comma-separated list
                           of NAME[:PROB] entries where NAME is a component
                           (group) and PROB the probability associated with
                           NAME (default 0.5).
  --random-seed=VALUE      seed value for --enable/disable-random
443 444
  --disable-valgrind-backtrace do not print a backtrace under Valgrind
                           (only applies to --disable-optimizations builds)
445 446 447

NOTE: Object files are built at the place where configure is launched.
EOF
448
  exit 0
449
}
450

451
quotes='""'
452
if test -t 1 && which tput >/dev/null 2>&1; then
453 454 455 456
    ncolors=$(tput colors)
    if test -n "$ncolors" && test $ncolors -ge 8; then
        bold_color=$(tput bold)
        warn_color=$(tput setaf 3)
457
        error_color=$(tput setaf 1)
458 459
        reset_color=$(tput sgr0)
    fi
460 461
    # 72 used instead of 80 since that's the default of pr
    ncols=$(tput cols)
462
fi
463
: ${ncols:=72}
464

465
log(){
466
    echo "$@" >> $logfile
467 468
}

469
log_file(){
Måns Rullgård's avatar
Måns Rullgård committed
470
    log BEGIN $1
471
    pr -n -t $1 >> $logfile
Måns Rullgård's avatar
Måns Rullgård committed
472 473 474
    log END $1
}

475 476 477 478 479
warn(){
    log "WARNING: $*"
    WARNINGS="${WARNINGS}WARNING: $*\n"
}

480
die(){
481 482
    log "$@"
    echo "$error_color$bold_color$@$reset_color"
483
    cat <<EOF
484

485
If you think configure made a mistake, make sure you are using the latest
486
version from Git.  If the latest version fails, report the problem to the
487
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
488
EOF
489
    if disabled logging; then
490
        cat <<EOF
491 492
Rerun configure with logging enabled (do not use --disable-logging), and
include the log this produces with your report.
493 494
EOF
    else
495
        cat <<EOF
496
Include the log file "$logfile" produced by configure as this will help
Lou Logan's avatar
Lou Logan committed
497
solve the problem.
498 499
EOF
    fi
500 501 502
    exit 1
}

503
# Avoid locale weirdness, besides we really just want to translate ASCII.
504
toupper(){
505
    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
506 507
}

508
tolower(){
509
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
510 511
}

512 513 514 515
c_escape(){
    echo "$*" | sed 's/["\\]/\\\0/g'
}

516 517
sh_quote(){
    v=$(echo "$1" | sed "s/'/'\\\\''/g")
518
    test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
519 520 521
    echo "$v"
}

522
cleanws(){
523
    echo "$@" | sed 's/^ *//;s/[[:space:]][[:space:]]*/ /g;s/ *$//'
524 525
}

526 527 528 529
filter(){
    pat=$1
    shift
    for v; do
530
        eval "case $v in $pat) echo $v ;; esac"
531 532 533
    done
}

534 535 536 537 538 539 540 541
filter_out(){
    pat=$1
    shift
    for v; do
        eval "case $v in $pat) ;; *) echo $v ;; esac"
    done
}

542 543 544
map(){
    m=$1
    shift
545
    for v; do eval $m; done
546 547
}

548 549 550 551 552 553
add_suffix(){
    suffix=$1
    shift
    for v; do echo ${v}${suffix}; done
}

554 555 556 557 558 559 560 561
set_all(){
    value=$1
    shift
    for var in $*; do
        eval $var=$value
    done
}

562 563 564 565 566 567 568 569
set_weak(){
    value=$1
    shift
    for var; do
        eval : \${$var:=$value}
    done
}

570 571 572 573
sanitize_var_name(){
    echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
}

574 575 576
set_safe(){
    var=$1
    shift
577
    eval $(sanitize_var_name "$var")='$*'
578 579 580
}

get_safe(){
581
    eval echo \$$(sanitize_var_name "$1")
582 583
}

584
pushvar(){
585 586 587 588
    for pvar in $*; do
        eval level=\${${pvar}_level:=0}
        eval ${pvar}_${level}="\$$pvar"
        eval ${pvar}_level=$(($level+1))
589 590 591 592
    done
}

popvar(){
593 594
    for pvar in $*; do
        eval level=\${${pvar}_level:-0}
595 596
        test $level = 0 && continue
        eval level=$(($level-1))
597 598 599
        eval $pvar="\${${pvar}_${level}}"
        eval ${pvar}_level=$level
        eval unset ${pvar}_${level}
600 601 602
    done
}

603 604 605 606 607 608 609 610
enable(){
    set_all yes $*
}

disable(){
    set_all no $*
}

611 612 613 614 615 616 617 618
enable_weak(){
    set_weak yes $*
}

disable_weak(){
    set_weak no $*
}

619
enable_safe(){
620 621 622
    for var; do
        enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
    done
623 624 625
}

disable_safe(){
626 627 628
    for var; do
        disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
    done
629 630
}

631 632 633
do_enable_deep(){
    for var; do
        enabled $var && continue
634
        eval sel="\$${var}_select"
635 636
        eval sgs="\$${var}_suggest"
        pushvar var sgs
637
        enable_deep $sel
638 639
        popvar sgs
        enable_deep_weak $sgs
640 641 642 643 644 645 646 647 648
        popvar var
    done
}

enable_deep(){
    do_enable_deep $*
    enable $*
}

649
enable_deep_weak(){
650 651 652 653 654 655 656
    for var; do
        disabled $var && continue
        pushvar var
        do_enable_deep $var
        popvar var
        enable_weak $var
    done
657 658
}

659
enabled(){
660
    test "${1#!}" = "$1" && op='=' || op=!=
661
    eval test "x\$${1#!}" $op "xyes"
662 663
}

664
disabled(){
665
    test "${1#!}" = "$1" && op='=' || op=!=
666
    eval test "x\$${1#!}" $op "xno"
667 668
}

669 670 671 672 673 674
enabled_all(){
    for opt; do
        enabled $opt || return 1
    done
}

675 676 677 678 679 680
disabled_all(){
    for opt; do
        disabled $opt || return 1
    done
}

681 682 683 684 685 686
enabled_any(){
    for opt; do
        enabled $opt && return 0
    done
}

687 688 689 690
disabled_any(){
    for opt; do
        disabled $opt && return 0
    done
691
    return 1
692 693
}

694 695
set_default(){
    for opt; do
696
        eval : \${$opt:=\$${opt}_default}
697 698 699
    done
}

700 701 702 703 704 705 706 707 708
is_in(){
    value=$1
    shift
    for var in $*; do
        [ $var = $value ] && return 0
    done
    return 1
}

709
do_check_deps(){
710
    for cfg; do
711
        cfg="${cfg#!}"
712 713 714
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
        disabled ${cfg}_checking && continue
        enable ${cfg}_checking
715
        append allopts $cfg
716

717
        eval dep_all="\$${cfg}_deps"
718
        eval dep_any="\$${cfg}_deps_any"
719
        eval dep_sel="\$${cfg}_select"
720
        eval dep_sgs="\$${cfg}_suggest"
721 722
        eval dep_ifa="\$${cfg}_if"
        eval dep_ifn="\$${cfg}_if_any"
723

724
        pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
725
        do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
726
        popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
727

728 729
        [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
        [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
Måns Rullgård's avatar
Måns Rullgård committed
730 731
        enabled_all  $dep_all || disable $cfg
        enabled_any  $dep_any || disable $cfg
732
        disabled_any $dep_sel && disable $cfg
733

734
        if enabled $cfg; then
735
            enable_deep $dep_sel
736
            enable_deep_weak $dep_sgs
737 738
        fi

739
        disable ${cfg}_checking
740 741 742
    done
}

743 744 745 746 747 748 749 750 751 752 753 754
check_deps(){
    unset allopts

    do_check_deps "$@"

    for cfg in $allopts; do
        enabled $cfg || continue
        eval dep_extralibs="\$${cfg}_extralibs"
        test -n "$dep_extralibs" && add_extralibs $dep_extralibs
    done
}

755 756
print_config(){
    pfx=$1
757 758
    files=$2
    shift 2
759 760 761 762 763 764 765 766 767 768 769 770 771 772
    map 'eval echo "$v \${$v:-no}"' "$@" |
    awk "BEGIN { split(\"$files\", files) }
        {
            c = \"$pfx\" toupper(\$1);
            v = \$2;
            sub(/yes/, 1, v);
            sub(/no/,  0, v);
            for (f in files) {
                file = files[f];
                if (file ~ /\\.h\$/) {
                    printf(\"#define %s %d\\n\", c, v) >>file;
                } else if (file ~ /\\.asm\$/) {
                    printf(\"%%define %s %d\\n\", c, v) >>file;
                } else if (file ~ /\\.mak\$/) {
773
                    n = -v ? \"\" : \"!\";
774
                    printf(\"%s%s=yes\\n\", n, c) >>file;
775 776 777 778 779 780
                } else if (file ~ /\\.texi\$/) {
                    pre = -v ? \"\" : \"@c \";
                    yesno = \$2;
                    c2 = tolower(c);
                    gsub(/_/, \"-\", c2);
                    printf(\"%s@set %s %s\\n\", pre, c2, yesno) >>file;
781 782 783
                }
            }
        }"
784 785
}

786 787 788 789
print_enabled(){
    suf=$1
    shift
    for v; do
790
        enabled $v && printf "%s\n" ${v%$suf}
791 792 793
    done
}

794 795 796 797 798 799
append(){
    var=$1
    shift
    eval "$var=\"\$$var $*\""
}

800 801 802 803 804 805
prepend(){
    var=$1
    shift
    eval "$var=\"$* \$$var\""
}

806 807 808 809 810 811 812 813 814
unique(){
    var=$1
    uniq_list=""
    for tok in $(eval echo \$$var); do
        uniq_list="$(filter_out $tok $uniq_list) $tok"
    done
    eval "$var=\"${uniq_list}\""
}

815
add_cppflags(){
816
    append CPPFLAGS "$@"
817 818
}

819
add_cflags(){
820
    append CFLAGS $($cflags_filter "$@")
821 822
}

Mohamed Naufal's avatar
Mohamed Naufal committed
823
add_cxxflags(){
824
    append CXXFLAGS $($cflags_filter "$@")
Mohamed Naufal's avatar
Mohamed Naufal committed
825 826
}

827
add_asflags(){
828
    append ASFLAGS $($asflags_filter "$@")
829 830
}

Luca Barbato's avatar
Luca Barbato committed
831 832 833 834
add_objcflags(){
    append OBJCFLAGS $($objcflags_filter "$@")
}

835
add_ldflags(){
836
    append LDFLAGS $($ldflags_filter "$@")
837 838
}

839 840 841 842
add_ldexeflags(){
    append LDEXEFLAGS $($ldflags_filter "$@")
}

843 844 845 846
add_ldlibflags(){
    append LDLIBFLAGS $($ldflags_filter "$@")
}

847
add_stripflags(){
848
    append ASMSTRIPFLAGS "$@"
849 850
}

851
add_extralibs(){
852
    prepend extralibs $($ldflags_filter "$@")
853 854
}

855 856 857 858
add_host_cppflags(){
    append host_cppflags "$@"
}

859 860 861 862 863 864
add_host_cflags(){
    append host_cflags $($host_cflags_filter "$@")
}

add_host_ldflags(){
    append host_ldflags $($host_ldflags_filter "$@")
865 866
}

867 868 869 870 871 872
add_compat(){
    append compat_objs $1
    shift
    map 'add_cppflags -D$v' "$@"
}

873
check_cmd(){
874
    log "$@"
875
    "$@" >> $logfile 2>&1
876 877
}

878 879 880 881 882
check_stat(){
    log check_stat "$@"
    stat "$1" >> $logfile 2>&1
}

883 884 885 886
cc_o(){
    eval printf '%s\\n' $CC_O
}

887 888 889 890
cc_e(){
    eval printf '%s\\n' $CC_E
}

891
check_cc(){
892
    log check_cc "$@"
893
    cat > $TMPC
894
    log_file $TMPC
895
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
896 897
}

Mohamed Naufal's avatar
Mohamed Naufal committed
898 899 900 901
check_cxx(){
    log check_cxx "$@"
    cat > $TMPCPP
    log_file $TMPCPP
902
    check_cmd $cxx $CPPFLAGS $CFLAGS $CXXFLAGS "$@" $CXX_C -o $TMPO $TMPCPP
Mohamed Naufal's avatar
Mohamed Naufal committed
903 904
}

Luca Barbato's avatar
Luca Barbato committed
905 906
check_objcc(){
    log check_objcc "$@"
907 908
    cat > $TMPM
    log_file $TMPM
909
    check_cmd $objcc -Werror=missing-prototypes $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPM
910 911
}

912 913
check_cpp(){
    log check_cpp "$@"
914
    cat > $TMPC
915
    log_file $TMPC
916
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
917 918
}

919 920 921 922
as_o(){
    eval printf '%s\\n' $AS_O
}

923 924
check_as(){
    log check_as "$@"
925 926 927
    cat > $TMPS
    log_file $TMPS
    check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
928 929
}

930 931
check_inline_asm(){
    log check_inline_asm "$@"
932
    name="$1"
933
    code="$2"
934
    shift 2
935
    disable $name
936
    check_cc "$@" <<EOF && enable $name
937
void foo(void){ __asm__ volatile($code); }
938 939 940
EOF
}

941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
check_inline_asm_flags(){
    log check_inline_asm_flags "$@"
    name="$1"
    code="$2"
    flags=''
    shift 2
    while [ "$1" != "" ]; do
      append flags $1
      shift
    done;
    disable $name
    cat > $TMPC <<EOF
void foo(void){ __asm__ volatile($code); }
EOF
    log_file $TMPC
    check_cmd $cc $CPPFLAGS $CFLAGS $flags "$@" $CC_C $(cc_o $TMPO) $TMPC &&
    enable $name && add_cflags $flags && add_asflags $flags && add_ldflags $flags
}

960 961 962 963 964 965
check_insn(){
    log check_insn "$@"
    check_inline_asm ${1}_inline "\"$2\""
    echo "$2" | check_as && enable ${1}_external || disable ${1}_external
}

Loren Merritt's avatar
Loren Merritt committed
966 967 968 969 970
check_yasm(){
    log check_yasm "$@"
    echo "$1" > $TMPS
    log_file $TMPS
    shift 1
971
    check_cmd $yasmexe $YASMFLAGS -Werror "$@" -o $TMPO $TMPS
Loren Merritt's avatar
Loren Merritt committed
972 973
}

974 975 976 977
ld_o(){
    eval printf '%s\\n' $LD_O
}

978
check_ld(){
979
    log check_ld "$@"
Mohamed Naufal's avatar
Mohamed Naufal committed
980 981
    type=$1
    shift 1
Jonas Bechtel's avatar
Jonas Bechtel committed
982 983
    flags=$(filter_out '-l*|*.so' $@)
    libs=$(filter '-l*|*.so' $@)
984
    check_$type $($cflags_filter $flags) || return
985 986
    flags=$($ldflags_filter $flags)
    libs=$($ldflags_filter $libs)
987
    check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
988 989
}

990 991 992 993 994 995 996
print_include(){
    hdr=$1
    test "${hdr%.h}" = "${hdr}" &&
        echo "#include $hdr"    ||
        echo "#include <$hdr>"
}

997 998 999 1000 1001 1002 1003 1004
check_code(){
    log check_code "$@"
    check=$1
    headers=$2
    code=$3
    shift 3
    {
        for hdr in $headers; do
1005
            print_include $hdr
1006 1007 1008 1009 1010
        done
        echo "int main(void) { $code; return 0; }"
    } | check_$check "$@"
}

1011 1012
check_cppflags(){
    log check_cppflags "$@"
1013
    check_cc "$@" <<EOF && append CPPFLAGS "$@"
1014 1015 1016 1017
int x;
EOF
}

1018 1019
test_cflags(){
    log test_cflags "$@"
1020
    set -- $($cflags_filter "$@")
1021
    check_cc "$@" <<EOF
1022 1023 1024 1025
int x;
EOF
}

1026 1027 1028 1029 1030
check_cflags(){
    log check_cflags "$@"
    test_cflags "$@" && add_cflags "$@"
}

Mohamed Naufal's avatar
Mohamed Naufal committed
1031 1032
check_cxxflags(){
    log check_cxxflags "$@"
1033
    set -- $($cflags_filter "$@")
Mohamed Naufal's avatar
Mohamed Naufal committed
1034 1035 1036 1037 1038
    check_cxx "$@" <<EOF && append CXXFLAGS "$@"
int x;
EOF
}

Luca Barbato's avatar
Luca Barbato committed
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
test_objcflags(){
    log test_cflags "$@"
    set -- $($cflags_filter "$@")
    check_objcc "$@" <<EOF
int x;
EOF
}

check_objcflags(){
    log check_cflags "$@"
    test_objcflags "$@" && add_objcflags "$@"
}

1052 1053
test_ldflags(){
    log test_ldflags "$@"
Mohamed Naufal's avatar
Mohamed Naufal committed
1054
    check_ld "cc" "$@" <<EOF
1055
int main(void){ return 0; }
1056 1057 1058
EOF
}

1059 1060 1061 1062 1063
check_ldflags(){
    log check_ldflags "$@"
    test_ldflags "$@" && add_ldflags "$@"
}

1064 1065 1066 1067 1068 1069
test_stripflags(){
    log test_stripflags "$@"
    # call check_cc to get a fresh TMPO
    check_cc <<EOF
int main(void) { return 0; }
EOF
1070
    check_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
1071 1072 1073 1074 1075 1076 1077
}

check_stripflags(){
    log check_stripflags "$@"
    test_stripflags "$@" && add_stripflags "$@"
}

1078
check_header(){
1079
    log check_header "$@"
1080 1081
    header=$1
    shift
1082 1083
    disable_safe $header
    check_cpp "$@" <<EOF && enable_safe $header
1084 1085 1086 1087 1088
#include <$header>
int x;
EOF
}

1089 1090
check_header_objcc(){
    log check_header_objcc "$@"
1091
    rm -f -- "$TMPO"
1092 1093
    header=$1
    shift
1094
    disable_safe $header
1095 1096 1097
    {
       echo "#include <$header>"
       echo "int main(void) { return 0; }"
1098
    } | check_objcc && check_stat "$TMPO" && enable_safe $headers
1099 1100
}

1101
check_func(){
1102
    log check_func "$@"
1103 1104
    func=$1
    shift
Måns Rullgård's avatar
Måns Rullgård committed
1105
    disable $func
Mohamed Naufal's avatar
Mohamed Naufal committed
1106
    check_ld "cc" "$@" <<EOF && enable $func
1107
extern int $func();
1108
int main(void){ $func(); }
1109 1110 1111
EOF
}

1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
check_complexfunc(){
    log check_complexfunc "$@"
    func=$1
    narg=$2
    shift 2
    test $narg = 2 && args="f, g" || args="f * I"
    disable $func
    check_ld "cc" "$@" <<EOF && enable $func
#include <complex.h>
#include <math.h>
float foo(complex float f, complex float g) { return $func($args); }
int main(void){ return (int) foo; }
EOF
}

1127
check_mathfunc(){
1128
    log check_mathfunc "$@"
1129
    func=$1
1130 1131 1132
    narg=$2
    shift 2
    test $narg = 2 && args="f, g" || args="f"
1133 1134 1135
    disable $func
    check_ld "cc" "$@" <<EOF && enable $func
#include <math.h>
1136
float foo(float f, float g) { return $func($args); }
1137 1138 1139 1140
int main(void){ return (int) foo; }
EOF
}

1141 1142
check_func_headers(){
    log check_func_headers "$@"
1143
    headers=$1
1144
    funcs=$2
1145
    shift 2
1146 1147
    {
        for hdr in $headers; do
1148
            print_include $hdr
1149 1150 1151 1152 1153
        done
        for func in $funcs; do
            echo "long check_$func(void) { return (long) $func; }"
        done
        echo "int main(void) { return 0; }"
Mohamed Naufal's avatar
Mohamed Naufal committed
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173
    } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
}

check_class_headers_cpp(){
    log check_class_headers_cpp "$@"
    headers=$1
    classes=$2
    shift 2
    {
        for hdr in $headers; do
            echo "#include <$hdr>"
        done
        echo "int main(void) { "
        i=1
        for class in $classes; do
            echo "$class obj$i;"
            i=$(expr $i + 1)
        done
        echo "return 0; }"
    } | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers
1174 1175
}

1176 1177 1178 1179
check_cpp_condition(){
    log check_cpp_condition "$@"
    header=$1
    condition=$2
1180
    shift 2
1181
    check_cpp "$@" <<EOF
1182 1183 1184 1185 1186 1187 1188
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}

1189 1190 1191 1192 1193
check_lib(){
    log check_lib "$@"
    header="$1"
    func="$2"
    shift 2
1194
    check_header $header && check_func $func "$@" && add_extralibs "$@"
1195 1196
}

1197 1198 1199
check_lib2(){
    log check_lib2 "$@"
    headers="$1"
1200
    funcs="$2"
1201
    shift 2
1202
    check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
1203 1204
}

Mohamed Naufal's avatar
Mohamed Naufal committed
1205 1206 1207 1208 1209 1210 1211 1212
check_lib_cpp(){
    log check_lib_cpp "$@"
    headers="$1"
    classes="$2"
    shift 2
    check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
}

1213 1214
check_pkg_config(){
    log check_pkg_config "$@"
1215 1216
    pkgandversion="$1"
    pkg="${1%% *}"
1217 1218 1219
    headers="$2"
    funcs="$3"
    shift 3
1220
    check_cmd $pkg_config --exists --print-errors $pkgandversion || return
1221 1222
    pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
    pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1223
    check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&