lavu: add LOCAL_ALIGNED_32
[libav.git] / configure
1 #!/bin/sh
2 #
3 # Libav configure script
4 #
5 # Copyright (c) 2000-2002 Fabrice Bellard
6 # Copyright (c) 2005-2008 Diego Biurrun
7 # Copyright (c) 2005-2008 Mans Rullgard
8 #
9
10 # Prevent locale nonsense from breaking basic text processing.
11 LC_ALL=C
12 export LC_ALL
13
14 # make sure we are running under a compatible shell
15 # try to make this part work with most shells
16
17 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 E1="$?"
25
26 (: ${foo?}) 2> /dev/null
27 E2="$?"
28
29 if test "$E1" != 0 || test "$E2" = 0; then
30     echo "Broken shell detected.  Trying alternatives."
31     export FF_CONF_EXEC
32     if test "0$FF_CONF_EXEC" -lt 1; then
33         FF_CONF_EXEC=1
34         try_exec bash "$0" "$@"
35     fi
36     if test "0$FF_CONF_EXEC" -lt 2; then
37         FF_CONF_EXEC=2
38         try_exec ksh "$0" "$@"
39     fi
40     if test "0$FF_CONF_EXEC" -lt 3; then
41         FF_CONF_EXEC=3
42         try_exec /usr/xpg4/bin/sh "$0" "$@"
43     fi
44     echo "No compatible shell script interpreter found."
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 LIBAV, 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 Libav."
50     if test "$BASH_VERSION" = '2.04.0(1)-release'; then
51         echo "This bash version ($BASH_VERSION) is broken on your platform."
52         echo "Upgrade to a later version if available."
53     fi
54     exit 1
55 fi
56
57 test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
58
59 show_help(){
60     cat <<EOF
61 Usage: configure [options]
62 Options: [defaults in brackets after descriptions]
63
64 Help options:
65   --help                   print this message
66   --list-decoders          show all available decoders
67   --list-encoders          show all available encoders
68   --list-hwaccels          show all available hardware accelerators
69   --list-demuxers          show all available demuxers
70   --list-muxers            show all available muxers
71   --list-parsers           show all available parsers
72   --list-protocols         show all available protocols
73   --list-bsfs              show all available bitstream filters
74   --list-indevs            show all available input devices
75   --list-outdevs           show all available output devices
76   --list-filters           show all available filters
77
78 Standard options:
79   --logfile=FILE           log tests and output to FILE [config.log]
80   --disable-logging        do not log configure debug information
81   --prefix=PREFIX          install in PREFIX [$prefix]
82   --bindir=DIR             install binaries in DIR [PREFIX/bin]
83   --datadir=DIR            install data files in DIR [PREFIX/share/avconv]
84   --docdir=DIR             install documentation in DIR [PREFIX/share/doc/libav]
85   --libdir=DIR             install libs in DIR [PREFIX/lib]
86   --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]
87   --incdir=DIR             install includes in DIR [PREFIX/include]
88   --mandir=DIR             install man page in DIR [PREFIX/share/man]
89   --enable-rpath           use rpath when linking programs [USE WITH CARE]
90
91 Licensing options:
92   --enable-gpl             allow use of GPL code, the resulting libs
93                            and binaries will be under GPL [no]
94   --enable-version3        upgrade (L)GPL to version 3 [no]
95   --enable-nonfree         allow use of nonfree code, the resulting libs
96                            and binaries will be unredistributable [no]
97
98 Configuration options:
99   --disable-static         do not build static libraries [no]
100   --enable-shared          build shared libraries [no]
101   --enable-small           optimize for size instead of speed
102   --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
103   --enable-gray            enable full grayscale support (slower color)
104   --disable-swscale-alpha  disable alpha channel support in swscale
105   --disable-all            disable building components, libraries and programs
106
107 Program options:
108   --disable-programs       do not build command line programs
109   --disable-avconv         disable avconv build
110   --disable-avplay         disable avplay build
111   --disable-avprobe        disable avprobe build
112   --disable-avserver       deprecated, does nothing
113
114 Component options:
115   --disable-doc            do not build documentation
116   --disable-avdevice       disable libavdevice build
117   --disable-avcodec        disable libavcodec build
118   --disable-avformat       disable libavformat build
119   --disable-avutil         disable libavutil build
120   --disable-swscale        disable libswscale build
121   --disable-avfilter       disable video filter support [no]
122   --disable-avresample     disable libavresample build [no]
123   --disable-pthreads       disable pthreads [auto]
124   --disable-w32threads     disable Win32 threads [auto]
125   --disable-network        disable network support [no]
126   --disable-dct            disable DCT code
127   --disable-error-resilience disable error resilience code
128   --disable-lsp            disable LSP code
129   --disable-lzo            disable LZO decoder code
130   --disable-mdct           disable MDCT code
131   --disable-rdft           disable RDFT code
132   --disable-fft            disable FFT code
133   --disable-faan           disable floating point AAN (I)DCT code
134
135 Individual component options:
136   --disable-everything     disable all components listed below
137   --disable-encoder=NAME   disable encoder NAME
138   --enable-encoder=NAME    enable encoder NAME
139   --disable-encoders       disable all encoders
140   --disable-decoder=NAME   disable decoder NAME
141   --enable-decoder=NAME    enable decoder NAME
142   --disable-decoders       disable all decoders
143   --disable-hwaccel=NAME   disable hwaccel NAME
144   --enable-hwaccel=NAME    enable hwaccel NAME
145   --disable-hwaccels       disable all hwaccels
146   --disable-muxer=NAME     disable muxer NAME
147   --enable-muxer=NAME      enable muxer NAME
148   --disable-muxers         disable all muxers
149   --disable-demuxer=NAME   disable demuxer NAME
150   --enable-demuxer=NAME    enable demuxer NAME
151   --disable-demuxers       disable all demuxers
152   --enable-parser=NAME     enable parser NAME
153   --disable-parser=NAME    disable parser NAME
154   --disable-parsers        disable all parsers
155   --enable-bsf=NAME        enable bitstream filter NAME
156   --disable-bsf=NAME       disable bitstream filter NAME
157   --disable-bsfs           disable all bitstream filters
158   --enable-protocol=NAME   enable protocol NAME
159   --disable-protocol=NAME  disable protocol NAME
160   --disable-protocols      disable all protocols
161   --enable-indev=NAME      enable input device NAME
162   --disable-indev=NAME     disable input device NAME
163   --disable-indevs         disable input devices
164   --enable-outdev=NAME     enable output device NAME
165   --disable-outdev=NAME    disable output device NAME
166   --disable-outdevs        disable output devices
167   --disable-devices        disable all devices
168   --enable-filter=NAME     enable filter NAME
169   --disable-filter=NAME    disable filter NAME
170   --disable-filters        disable all filters
171
172 External library support:
173
174   Using any of the following switches will allow Libav to link to the
175   corresponding external library. All the components depending on that library
176   will become enabled, if all their other dependencies are met and they are not
177   explicitly disabled. E.g. --enable-libwavpack will enable linking to
178   libwavpack and allow the libwavpack encoder to be built, unless it is
179   specifically disabled with --disable-encoder=libwavpack.
180
181   Note that only the system libraries are auto-detected. All the other external
182   libraries must be explicitly enabled.
183
184   Also note that the following help text describes the purpose of the libraries
185   themselves, not all their features will necessarily be usable by Libav.
186
187   --enable-avisynth          video frameserver
188   --enable-bzlib             bzip2 compression [autodetect]
189   --enable-frei0r            video filtering plugins
190   --enable-gnutls            crypto
191   --enable-libbs2b           Bauer stereophonic-to-binaural DSP
192   --enable-libcdio           audio CD input
193   --enable-libdc1394         IEEE 1394/Firewire camera input
194   --enable-libdcadec         DCA audio decoding
195   --enable-libfaac           AAC audio encoding
196   --enable-libfdk-aac        AAC audio encoding/decoding
197   --enable-libfontconfig     font configuration and management
198   --enable-libfreetype       font rendering
199   --enable-libgsm            GSM audio encoding/decoding
200   --enable-libilbc           ILBC audio encoding/decoding
201   --enable-libkvazaar        HEVC video encoding
202   --enable-libmp3lame        MP3 audio encoding
203   --enable-libopencore-amrnb AMR-NB audio encoding/decoding
204   --enable-libopencore-amrwb AMR-WB audio decoding
205   --enable-libopencv         computer vision
206   --enable-libopenh264       H.264 video encoding/decoding
207   --enable-libopenjpeg       JPEG 2000 image encoding/decoding
208   --enable-libopus           Opus audio encoding/decoding
209   --enable-libpulse          Pulseaudio sound server
210   --enable-librtmp           RTMP streaming
211   --enable-libschroedinger   Dirac video encoding/decoding
212   --enable-libsnappy         snappy compression
213   --enable-libspeex          Speex audio encoding/decoding
214   --enable-libtheora         Theora video encoding/decoding
215   --enable-libtwolame        MP2 audio encoding
216   --enable-libvo-aacenc      AAC audio encoding
217   --enable-libvo-amrwbenc    AMR-WB audio encoding
218   --enable-libvorbis         Vorbis audio encoding/decoding
219   --enable-libvpx            VP* video encoding/decoding
220   --enable-libwavpack        Wavpack audio encoding/decoding
221   --enable-libwebp           WebP image encoding/decoding
222   --enable-libx264           H.264 video encoding
223   --enable-libx265           HEVC video encoding
224   --enable-libxavs           Chinese AVS video encoding
225   --enable-libxcb            X window system protocol communication
226   --enable-libxcb-shm        X11 shm communication [auto]
227   --enable-libxcb-xfixes     X11 mouse rendering [auto]
228   --enable-libxvid           MPEG-4 ASP video encoding
229   --enable-openssl           crypto
230   --enable-zlib              compression [autodetect]
231
232   The following libraries provide various hardware acceleration features:
233   --enable-cuda    Nvidia CUDA (dynamically linked)
234   --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto]
235   --enable-dxva2   Microsoft DirectX 9 video acceleration [auto]
236   --enable-libmfx  Intel MediaSDK (AKA Quick Sync Video)
237   --enable-libnpp  Nvidia CUDA processing
238   --enable-mmal    Broadcom Multi-Media Abstraction Layer (Raspberry Pi)
239   --enable-nvenc   Nvidia video encoding
240   --enable-omx     OpenMAX IL
241   --enable-omx-rpi OpenMAX IL for Raspberry Pi
242   --enable-vaapi   Video Acceleration API (mainly Unix/Intel)
243   --enable-vda     Apple Video Decode Acceleration [auto]
244   --enable-vdpau   Nvidia Video Decode and Presentation API for Unix [auto]
245
246 Toolchain options:
247   --arch=ARCH              select architecture [$arch]
248   --cpu=CPU                select the minimum required CPU (affects
249                            instruction selection, may crash on older CPUs)
250   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
251   --enable-cross-compile   assume a cross-compiler is used
252   --sysroot=PATH           root of cross-build tree
253   --sysinclude=PATH        location of cross-build system headers
254   --target-os=OS           compiler targets OS [$target_os]
255   --target-exec=CMD        command to run executables on target
256   --target-path=DIR        path to view of build directory on target
257   --target-samples=DIR     path to samples directory on target
258   --toolchain=NAME         set tool defaults according to NAME
259   --nm=NM                  use nm tool
260   --ar=AR                  use archive tool AR [$ar_default]
261   --as=AS                  use assembler AS [$as_default]
262   --cc=CC                  use C compiler CC [$cc_default]
263   --objcc=OCC              use ObjC compiler OCC [$cc_default]
264   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
265   --ld=LD                  use linker LD
266   --pkg-config=PKGCONFIG   use pkg-config tool PKGCONFIG [$pkg_config_default]
267   --pkg-config-flags=FLAGS pass additional flags to pkgconf []
268   --host-cc=HOSTCC         use host C compiler HOSTCC
269   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
270   --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
271   --host-ld=HOSTLD         use host linker HOSTLD
272   --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
273   --host-libs=HLIBS        use libs HLIBS when linking for host
274   --host-os=OS             compiler host OS [$target_os]
275   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
276   --extra-objcflags=FLAGS  add FLAGS to OBJCFLAGS [$CFLAGS]
277   --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
278   --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS [$LDEXEFLAGS]
279   --extra-libs=ELIBS       add ELIBS [$ELIBS]
280   --extra-version=STRING   version string suffix []
281   --optflags=OPTFLAGS      override optimization-related compiler flags
282   --build-suffix=SUFFIX    library name suffix []
283   --enable-pic             build position-independent code
284   --enable-thumb           compile for Thumb instruction set
285   --enable-lto             use link-time optimization
286   --env="ENV=override"     override the environment variables
287
288 Advanced options (experts only):
289   --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
290   --custom-allocator=NAME  use a supported custom allocator
291   --disable-symver         disable symbol versioning
292   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
293   --disable-safe-bitstream-reader
294                            disable buffer boundary checking in bitreaders
295                            (faster, but may crash)
296   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
297   --enable-sram            allow use of on-chip SRAM
298
299 Optimization options (experts only):
300   --disable-asm            disable all assembly optimizations
301   --disable-altivec        disable AltiVec optimizations
302   --disable-vsx            disable VSX optimizations
303   --disable-power8         disable POWER8 optimizations
304   --disable-amd3dnow       disable 3DNow! optimizations
305   --disable-amd3dnowext    disable 3DNow! extended optimizations
306   --disable-mmx            disable MMX optimizations
307   --disable-mmxext         disable MMXEXT optimizations
308   --disable-sse            disable SSE optimizations
309   --disable-sse2           disable SSE2 optimizations
310   --disable-sse3           disable SSE3 optimizations
311   --disable-ssse3          disable SSSE3 optimizations
312   --disable-sse4           disable SSE4 optimizations
313   --disable-sse42          disable SSE4.2 optimizations
314   --disable-avx            disable AVX optimizations
315   --disable-xop            disable XOP optimizations
316   --disable-fma3           disable FMA3 optimizations
317   --disable-fma4           disable FMA4 optimizations
318   --disable-avx2           disable AVX2 optimizations
319   --disable-armv5te        disable armv5te optimizations
320   --disable-armv6          disable armv6 optimizations
321   --disable-armv6t2        disable armv6t2 optimizations
322   --disable-vfp            disable VFP optimizations
323   --disable-neon           disable NEON optimizations
324   --disable-inline-asm     disable use of inline assembly
325   --disable-yasm           disable use of nasm/yasm assembly
326
327 Developer options (useful when working on Libav itself):
328   --disable-debug          disable debugging symbols
329   --enable-debug=LEVEL     set the debug level [$debuglevel]
330   --disable-optimizations  disable compiler optimizations
331   --enable-extra-warnings  enable more compiler warnings
332   --samples=PATH           location of test samples for FATE, if not set use
333                            \$LIBAV_SAMPLES at make invocation time.
334   --enable-neon-clobber-test check NEON registers for clobbering (should be
335                            used only for debugging purposes)
336   --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
337                            should be used only for debugging purposes)
338   --enable-random          randomly enable/disable components
339   --disable-random
340   --enable-random=LIST     randomly enable/disable specific components or
341   --disable-random=LIST    component groups. LIST is a comma-separated list
342                            of NAME[:PROB] entries where NAME is a component
343                            (group) and PROB the probability associated with
344                            NAME (default 0.5).
345   --random-seed=VALUE      seed value for --enable/disable-random
346   --disable-valgrind-backtrace do not print a backtrace under Valgrind
347                            (only applies to --disable-optimizations builds)
348
349 NOTE: Object files are built at the place where configure is launched.
350 EOF
351   exit 0
352 }
353
354 quotes='""'
355
356 log(){
357     echo "$@" >> $logfile
358 }
359
360 log_file(){
361     log BEGIN $1
362     i=1
363     while read line; do
364         printf '%5s   %s\n' "${i}" "${line}"
365         i=$(($i+1))
366     done < $1 >> $logfile
367     log END $1
368 }
369
370 echolog(){
371     log "$@"
372     echo "$@"
373 }
374
375 warn(){
376     log "WARNING: $*"
377     WARNINGS="${WARNINGS}WARNING: $*\n"
378 }
379
380 die(){
381     echolog "$@"
382     cat <<EOF
383
384 If you think configure made a mistake, make sure you are using the latest
385 version from Git.  If the latest version fails, report the problem to the
386 libav-tools@libav.org mailing list or IRC #libav on irc.freenode.net.
387 EOF
388     if disabled logging; then
389         cat <<EOF
390 Rerun configure with logging enabled (do not use --disable-logging), and
391 include the log this produces with your report.
392 EOF
393     else
394         cat <<EOF
395 Include the log file "$logfile" produced by configure as this will help
396 solving the problem.
397 EOF
398     fi
399     exit 1
400 }
401
402 # Avoid locale weirdness, besides we really just want to translate ASCII.
403 toupper(){
404     echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
405 }
406
407 tolower(){
408     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
409 }
410
411 c_escape(){
412     echo "$*" | sed 's/["\\]/\\\0/g'
413 }
414
415 sh_quote(){
416     v=$(echo "$1" | sed "s/'/'\\\\''/g")
417     test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
418     echo "$v"
419 }
420
421 cleanws(){
422     echo "$@" | sed 's/^ *//;s/  */ /g;s/ *$//'
423 }
424
425 filter(){
426     pat=$1
427     shift
428     for v; do
429         eval "case $v in $pat) echo $v ;; esac"
430     done
431 }
432
433 filter_out(){
434     pat=$1
435     shift
436     for v; do
437         eval "case $v in $pat) ;; *) echo $v ;; esac"
438     done
439 }
440
441 map(){
442     m=$1
443     shift
444     for v; do eval $m; done
445 }
446
447 add_suffix(){
448     suffix=$1
449     shift
450     for v; do echo ${v}${suffix}; done
451 }
452
453 set_all(){
454     value=$1
455     shift
456     for var in $*; do
457         eval $var=$value
458     done
459 }
460
461 set_weak(){
462     value=$1
463     shift
464     for var; do
465         eval : \${$var:=$value}
466     done
467 }
468
469 sanitize_var_name(){
470     echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
471 }
472
473 set_safe(){
474     var=$1
475     shift
476     eval $(sanitize_var_name "$var")='$*'
477 }
478
479 get_safe(){
480     eval echo \$$(sanitize_var_name "$1")
481 }
482
483 pushvar(){
484     for pvar in $*; do
485         eval level=\${${pvar}_level:=0}
486         eval ${pvar}_${level}="\$$pvar"
487         eval ${pvar}_level=$(($level+1))
488     done
489 }
490
491 popvar(){
492     for pvar in $*; do
493         eval level=\${${pvar}_level:-0}
494         test $level = 0 && continue
495         eval level=$(($level-1))
496         eval $pvar="\${${pvar}_${level}}"
497         eval ${pvar}_level=$level
498         eval unset ${pvar}_${level}
499     done
500 }
501
502 enable(){
503     set_all yes $*
504 }
505
506 disable(){
507     set_all no $*
508 }
509
510 enable_weak(){
511     set_weak yes $*
512 }
513
514 disable_weak(){
515     set_weak no $*
516 }
517
518 enable_safe(){
519     for var; do
520         enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
521     done
522 }
523
524 disable_safe(){
525     for var; do
526         disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
527     done
528 }
529
530 do_enable_deep(){
531     for var; do
532         enabled $var && continue
533         eval sel="\$${var}_select"
534         eval sgs="\$${var}_suggest"
535         pushvar var sgs
536         enable_deep $sel
537         popvar sgs
538         enable_deep_weak $sgs
539         popvar var
540     done
541 }
542
543 enable_deep(){
544     do_enable_deep $*
545     enable $*
546 }
547
548 enable_deep_weak(){
549     for var; do
550         disabled $var && continue
551         pushvar var
552         do_enable_deep $var
553         popvar var
554         enable_weak $var
555     done
556 }
557
558 enabled(){
559     test "${1#!}" = "$1" && op== || op=!=
560     eval test "x\$${1#!}" $op "xyes"
561 }
562
563 disabled(){
564     test "${1#!}" = "$1" && op== || op=!=
565     eval test "x\$${1#!}" $op "xno"
566 }
567
568 enabled_all(){
569     for opt; do
570         enabled $opt || return 1
571     done
572 }
573
574 disabled_all(){
575     for opt; do
576         disabled $opt || return 1
577     done
578 }
579
580 enabled_any(){
581     for opt; do
582         enabled $opt && return 0
583     done
584 }
585
586 disabled_any(){
587     for opt; do
588         disabled $opt && return 0
589     done
590     return 1
591 }
592
593 set_default(){
594     for opt; do
595         eval : \${$opt:=\$${opt}_default}
596     done
597 }
598
599 is_in(){
600     value=$1
601     shift
602     for var in $*; do
603         [ $var = $value ] && return 0
604     done
605     return 1
606 }
607
608 do_check_deps(){
609     for cfg; do
610         cfg="${cfg#!}"
611         enabled ${cfg}_checking && die "Circular dependency for $cfg."
612         disabled ${cfg}_checking && continue
613         enable ${cfg}_checking
614         append allopts $cfg
615
616         eval dep_all="\$${cfg}_deps"
617         eval dep_any="\$${cfg}_deps_any"
618         eval dep_sel="\$${cfg}_select"
619         eval dep_sgs="\$${cfg}_suggest"
620         eval dep_ifa="\$${cfg}_if"
621         eval dep_ifn="\$${cfg}_if_any"
622
623         pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
624         do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
625         popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
626
627         [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
628         [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
629         enabled_all  $dep_all || disable $cfg
630         enabled_any  $dep_any || disable $cfg
631         disabled_any $dep_sel && disable $cfg
632
633         if enabled $cfg; then
634             enable_deep $dep_sel
635             enable_deep_weak $dep_sgs
636         fi
637
638         disable ${cfg}_checking
639     done
640 }
641
642 check_deps(){
643     unset allopts
644
645     do_check_deps "$@"
646
647     for cfg in $allopts; do
648         enabled $cfg || continue
649         eval dep_extralibs="\$${cfg}_extralibs"
650         test -n "$dep_extralibs" && add_extralibs $dep_extralibs
651     done
652 }
653
654 print_config(){
655     pfx=$1
656     files=$2
657     shift 2
658     map 'eval echo "$v \${$v:-no}"' "$@" |
659     awk "BEGIN { split(\"$files\", files) }
660         {
661             c = \"$pfx\" toupper(\$1);
662             v = \$2;
663             sub(/yes/, 1, v);
664             sub(/no/,  0, v);
665             for (f in files) {
666                 file = files[f];
667                 if (file ~ /\\.h\$/) {
668                     printf(\"#define %s %d\\n\", c, v) >>file;
669                 } else if (file ~ /\\.asm\$/) {
670                     printf(\"%%define %s %d\\n\", c, v) >>file;
671                 } else if (file ~ /\\.mak\$/) {
672                     n = -v ? \"\" : \"!\";
673                     printf(\"%s%s=yes\\n\", n, c) >>file;
674                 }
675             }
676         }"
677 }
678
679 print_enabled(){
680     suf=$1
681     shift
682     for v; do
683         enabled $v && printf "%s\n" ${v%$suf}
684     done
685 }
686
687 append(){
688     var=$1
689     shift
690     eval "$var=\"\$$var $*\""
691 }
692
693 prepend(){
694     var=$1
695     shift
696     eval "$var=\"$* \$$var\""
697 }
698
699 unique(){
700     var=$1
701     uniq_list=""
702     for tok in $(eval echo \$$var); do
703         uniq_list="$(filter_out $tok $uniq_list) $tok"
704     done
705     eval "$var=\"${uniq_list}\""
706 }
707
708 add_cppflags(){
709     append CPPFLAGS "$@"
710 }
711
712 add_cflags(){
713     append CFLAGS $($cflags_filter "$@")
714 }
715
716 add_asflags(){
717     append ASFLAGS $($asflags_filter "$@")
718 }
719
720 add_objcflags(){
721     append OBJCFLAGS $($objcflags_filter "$@")
722 }
723
724 add_ldflags(){
725     append LDFLAGS $($ldflags_filter "$@")
726 }
727
728 add_ldexeflags(){
729     append LDEXEFLAGS $($ldflags_filter "$@")
730 }
731
732 add_stripflags(){
733     append STRIPFLAGS "$@"
734 }
735
736 add_extralibs(){
737     prepend extralibs $($ldflags_filter "$@")
738 }
739
740 add_host_cppflags(){
741     append host_cppflags "$@"
742 }
743
744 add_host_cflags(){
745     append host_cflags $($host_cflags_filter "$@")
746 }
747
748 add_host_ldflags(){
749     append host_ldflags $($host_ldflags_filter "$@")
750 }
751
752 add_compat(){
753     append compat_objs $1
754     shift
755     map 'add_cppflags -D$v' "$@"
756 }
757
758 check_cmd(){
759     log "$@"
760     "$@" >> $logfile 2>&1
761 }
762
763 cc_o(){
764     eval printf '%s\\n' $CC_O
765 }
766
767 cc_e(){
768     eval printf '%s\\n' $CC_E
769 }
770
771 check_cc(){
772     log check_cc "$@"
773     cat > $TMPC
774     log_file $TMPC
775     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
776 }
777
778 check_objcc(){
779     log check_objcc "$@"
780     cat > $TMPC
781     log_file $TMPC
782     check_cmd $objcc $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) $TMPC
783 }
784
785 check_cpp(){
786     log check_cpp "$@"
787     cat > $TMPC
788     log_file $TMPC
789     check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
790 }
791
792 as_o(){
793     eval printf '%s\\n' $AS_O
794 }
795
796 check_as(){
797     log check_as "$@"
798     cat > $TMPS
799     log_file $TMPS
800     check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
801 }
802
803 check_inline_asm(){
804     log check_inline_asm "$@"
805     name="$1"
806     code="$2"
807     shift 2
808     disable $name
809     check_cc "$@" <<EOF && enable $name
810 void foo(void){ __asm__ volatile($code); }
811 EOF
812 }
813
814 check_insn(){
815     log check_insn "$@"
816     check_inline_asm ${1}_inline "\"$2\""
817     echo "$2" | check_as && enable ${1}_external || disable ${1}_external
818 }
819
820 check_yasm(){
821     log check_yasm "$@"
822     echo "$1" > $TMPS
823     log_file $TMPS
824     shift 1
825     check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
826 }
827
828 ld_o(){
829     eval printf '%s\\n' $LD_O
830 }
831
832 check_ld(){
833     log check_ld "$@"
834     flags=$(filter_out '-l*' "$@")
835     libs=$(filter '-l*' "$@")
836     check_cc $($cflags_filter $flags) || return
837     flags=$($ldflags_filter $flags)
838     libs=$($ldflags_filter $libs)
839     check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
840 }
841
842 print_include(){
843     hdr=$1
844     test "${hdr%.h}" = "${hdr}" &&
845         echo "#include $hdr"    ||
846         echo "#include <$hdr>"
847 }
848
849 check_code(){
850     log check_code "$@"
851     check=$1
852     headers=$2
853     code=$3
854     shift 3
855     {
856         for hdr in $headers; do
857             print_include $hdr
858         done
859         echo "int main(void) { $code; return 0; }"
860     } | check_$check "$@"
861 }
862
863 check_cppflags(){
864     log check_cppflags "$@"
865     check_cc "$@" <<EOF && append CPPFLAGS "$@"
866 int x;
867 EOF
868 }
869
870 test_cflags(){
871     log test_cflags "$@"
872     set -- $($cflags_filter "$@")
873     check_cc "$@" <<EOF
874 int x;
875 EOF
876 }
877
878 check_cflags(){
879     log check_cflags "$@"
880     test_cflags "$@" && add_cflags "$@"
881 }
882
883 test_objcflags(){
884     log test_cflags "$@"
885     set -- $($cflags_filter "$@")
886     check_objcc "$@" <<EOF
887 int x;
888 EOF
889 }
890
891 check_objcflags(){
892     log check_cflags "$@"
893     test_objcflags "$@" && add_objcflags "$@"
894 }
895
896 test_ldflags(){
897     log test_ldflags "$@"
898     check_ld "$@" <<EOF
899 int main(void){ return 0; }
900 EOF
901 }
902
903 check_ldflags(){
904     log check_ldflags "$@"
905     test_ldflags "$@" && add_ldflags "$@"
906 }
907
908 test_stripflags(){
909     log test_stripflags "$@"
910     # call check_cc to get a fresh TMPO
911     check_cc <<EOF
912 int main(void) { return 0; }
913 EOF
914     check_cmd $strip $STRIPFLAGS "$@" $TMPO
915 }
916
917 check_stripflags(){
918     log check_stripflags "$@"
919     test_stripflags "$@" && add_stripflags "$@"
920 }
921
922 check_header(){
923     log check_header "$@"
924     header=$1
925     shift
926     disable_safe $header
927     check_cpp "$@" <<EOF && enable_safe $header
928 #include <$header>
929 int x;
930 EOF
931 }
932
933 check_func(){
934     log check_func "$@"
935     func=$1
936     shift
937     disable $func
938     check_ld "$@" <<EOF && enable $func
939 extern int $func();
940 int main(void){ $func(); }
941 EOF
942 }
943
944 check_mathfunc(){
945     log check_mathfunc "$@"
946     func=$1
947     narg=$2
948     shift 2
949     test $narg = 2 && args="f, g" || args="f"
950     disable $func
951     check_ld "$@" <<EOF && enable $func
952 #include <math.h>
953 float foo(float f, float g) { return $func($args); }
954 int main(void){ return 0; }
955 EOF
956 }
957
958 check_func_headers(){
959     log check_func_headers "$@"
960     headers=$1
961     funcs=$2
962     shift 2
963     {
964         for hdr in $headers; do
965             print_include $hdr
966         done
967         for func in $funcs; do
968             echo "long check_$func(void) { return (long) $func; }"
969         done
970         echo "int main(void) { return 0; }"
971     } | check_ld "$@" && enable $funcs && enable_safe $headers
972 }
973
974 check_cpp_condition(){
975     log check_cpp_condition "$@"
976     header=$1
977     condition=$2
978     shift 2
979     check_cpp "$@" <<EOF
980 #include <$header>
981 #if !($condition)
982 #error "unsatisfied condition: $condition"
983 #endif
984 EOF
985 }
986
987 check_lib(){
988     log check_lib "$@"
989     header="$1"
990     func="$2"
991     shift 2
992     check_header $header && check_func $func "$@" && add_extralibs "$@"
993 }
994
995 check_lib2(){
996     log check_lib2 "$@"
997     headers="$1"
998     funcs="$2"
999     shift 2
1000     check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
1001 }
1002
1003 check_pkg_config(){
1004     log check_pkg_config "$@"
1005     pkg="$1"
1006     headers="$2"
1007     funcs="$3"
1008     shift 3
1009     check_cmd $pkg_config --exists --print-errors $pkg || return
1010     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
1011     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
1012     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
1013         set_safe "${pkg}_cflags" $pkg_cflags   &&
1014         set_safe "${pkg}_libs"   $pkg_libs
1015 }
1016
1017 check_exec(){
1018     check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
1019 }
1020
1021 check_exec_crash(){
1022     code=$(cat)
1023
1024     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
1025     # are safe but may not be available everywhere.  Thus we use
1026     # raise(SIGTERM) instead.  The check is run in a subshell so we
1027     # can redirect the "Terminated" message from the shell.  SIGBUS
1028     # is not defined by standard C so it is used conditionally.
1029
1030     (check_exec "$@") >> $logfile 2>&1 <<EOF
1031 #include <signal.h>
1032 static void sighandler(int sig){
1033     raise(SIGTERM);
1034 }
1035 int foo(void){
1036     $code
1037 }
1038 int (*func_ptr)(void) = foo;
1039 int main(void){
1040     signal(SIGILL, sighandler);
1041     signal(SIGFPE, sighandler);
1042     signal(SIGSEGV, sighandler);
1043 #ifdef SIGBUS
1044     signal(SIGBUS, sighandler);
1045 #endif
1046     return func_ptr();
1047 }
1048 EOF
1049 }
1050
1051 check_type(){
1052     log check_type "$@"
1053     headers=$1
1054     type=$2
1055     shift 2
1056     disable_safe "$type"
1057     check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
1058 }
1059
1060 check_struct(){
1061     log check_struct "$@"
1062     headers=$1
1063     struct=$2
1064     member=$3
1065     shift 3
1066     disable_safe "${struct}_${member}"
1067     check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
1068         enable_safe "${struct}_${member}"
1069 }
1070
1071 check_builtin(){
1072     log check_builtin "$@"
1073     name=$1
1074     headers=$2
1075     builtin=$3
1076     shift 3
1077     disable "$name"
1078     check_code ld "$headers" "$builtin" "$@" && enable "$name"
1079 }
1080
1081 check_compile_assert(){
1082     log check_compile_assert "$@"
1083     name=$1
1084     headers=$2
1085     condition=$3
1086     shift 3
1087     disable "$name"
1088     check_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
1089 }
1090
1091 require(){
1092     name="$1"
1093     header="$2"
1094     func="$3"
1095     shift 3
1096     check_lib $header $func "$@" || die "ERROR: $name not found"
1097 }
1098
1099 require2(){
1100     name="$1"
1101     headers="$2"
1102     func="$3"
1103     shift 3
1104     check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
1105 }
1106
1107 require_pkg_config(){
1108     pkg="$1"
1109     check_pkg_config "$@" || die "ERROR: $pkg not found"
1110     add_cflags    $(get_safe "${pkg}_cflags")
1111     add_extralibs $(get_safe "${pkg}_libs")
1112 }
1113
1114 hostcc_e(){
1115     eval printf '%s\\n' $HOSTCC_E
1116 }
1117
1118 hostcc_o(){
1119     eval printf '%s\\n' $HOSTCC_O
1120 }
1121
1122 check_host_cc(){
1123     log check_host_cc "$@"
1124     cat > $TMPC
1125     log_file $TMPC
1126     check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
1127 }
1128
1129 check_host_cpp(){
1130     log check_host_cpp "$@"
1131     cat > $TMPC
1132     log_file $TMPC
1133     check_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
1134 }
1135
1136 check_host_cppflags(){
1137     log check_host_cppflags "$@"
1138     check_host_cc "$@" <<EOF && append host_cppflags "$@"
1139 int x;
1140 EOF
1141 }
1142
1143 check_host_cflags(){
1144     log check_host_cflags "$@"
1145     set -- $($host_cflags_filter "$@")
1146     check_host_cc "$@" <<EOF && append host_cflags "$@"
1147 int x;
1148 EOF
1149 }
1150
1151 check_host_cpp_condition(){
1152     log check_host_cpp_condition "$@"
1153     header=$1
1154     condition=$2
1155     shift 2
1156     check_host_cpp "$@" <<EOF
1157 #include <$header>
1158 #if !($condition)
1159 #error "unsatisfied condition: $condition"
1160 #endif
1161 EOF
1162 }
1163
1164 apply(){
1165     file=$1
1166     shift
1167     "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
1168 }
1169
1170 cp_if_changed(){
1171     cmp -s "$1" "$2" && echo "$2 is unchanged" && return
1172     mkdir -p "$(dirname $2)"
1173     $cp_f "$1" "$2"
1174 }
1175
1176 # CONFIG_LIST contains configurable options, while HAVE_LIST is for
1177 # system-dependent things.
1178
1179 AVCODEC_COMPONENTS="
1180     bsfs
1181     decoders
1182     encoders
1183     hwaccels
1184     parsers
1185 "
1186
1187 AVDEVICE_COMPONENTS="
1188     indevs
1189     outdevs
1190 "
1191 AVFILTER_COMPONENTS="
1192     filters
1193 "
1194 AVFORMAT_COMPONENTS="
1195     demuxers
1196     muxers
1197     protocols
1198 "
1199
1200 AVRESAMPLE_COMPONENTS=""
1201 AVUTIL_COMPONENTS=""
1202
1203 COMPONENT_LIST="
1204     $AVCODEC_COMPONENTS
1205     $AVDEVICE_COMPONENTS
1206     $AVFILTER_COMPONENTS
1207     $AVFORMAT_COMPONENTS
1208     $AVRESAMPLE_COMPONENTS
1209     $AVUTIL_COMPONENTS
1210 "
1211
1212 EXAMPLE_LIST="
1213     avcodec_example
1214     filter_audio_example
1215     metadata_example
1216     output_example
1217     qsvdec_example
1218     transcode_aac_example
1219 "
1220
1221 HWACCEL_LIBRARY_NONFREE_LIST="
1222     cuda
1223     libnpp
1224 "
1225 HWACCEL_LIBRARY_LIST="
1226     $HWACCEL_LIBRARY_NONFREE_LIST
1227     d3d11va
1228     dxva2
1229     libmfx
1230     mmal
1231     nvenc
1232     omx
1233     vaapi
1234     vda
1235     vdpau
1236 "
1237
1238 EXTERNAL_LIBRARY_GPL_LIST="
1239     libcdio
1240     libx264
1241     libx265
1242     libxavs
1243     libxvid
1244 "
1245
1246 EXTERNAL_LIBRARY_NONFREE_LIST="
1247     libfaac
1248     libfdk_aac
1249     openssl
1250 "
1251
1252 EXTERNAL_LIBRARY_VERSION3_LIST="
1253     libopencore_amrnb
1254     libopencore_amrwb
1255     libvo_aacenc
1256     libvo_amrwbenc
1257 "
1258
1259 EXTERNAL_LIBRARY_LIST="
1260     $EXTERNAL_LIBRARY_GPL_LIST
1261     $EXTERNAL_LIBRARY_NONFREE_LIST
1262     $EXTERNAL_LIBRARY_VERSION3_LIST
1263     avisynth
1264     bzlib
1265     frei0r
1266     gnutls
1267     libbs2b
1268     libdc1394
1269     libdcadec
1270     libfontconfig
1271     libfreetype
1272     libgsm
1273     libilbc
1274     libkvazaar
1275     libmp3lame
1276     libopencv
1277     libopenh264
1278     libopenjpeg
1279     libopus
1280     libpulse
1281     librtmp
1282     libschroedinger
1283     libsnappy
1284     libspeex
1285     libtheora
1286     libtwolame
1287     libvorbis
1288     libvpx
1289     libwavpack
1290     libwebp
1291     libxcb
1292     libxcb_shm
1293     libxcb_xfixes
1294     zlib
1295 "
1296
1297 FEATURE_LIST="
1298     gray
1299     hardcoded_tables
1300     omx_rpi
1301     runtime_cpudetect
1302     safe_bitstream_reader
1303     shared
1304     small
1305     sram
1306     static
1307     swscale_alpha
1308 "
1309
1310 LIBRARY_LIST="
1311     avcodec
1312     avdevice
1313     avfilter
1314     avformat
1315     avresample
1316     avutil
1317     swscale
1318 "
1319
1320 LICENSE_LIST="
1321     gpl
1322     nonfree
1323     version3
1324 "
1325
1326 PROGRAM_LIST="
1327     avconv
1328     avplay
1329     avprobe
1330 "
1331
1332 SUBSYSTEM_LIST="
1333     dct
1334     doc
1335     error_resilience
1336     faan
1337     fft
1338     lsp
1339     lzo
1340     mdct
1341     network
1342     rdft
1343 "
1344
1345 CONFIG_LIST="
1346     $COMPONENT_LIST
1347     $EXAMPLE_LIST
1348     $EXTERNAL_LIBRARY_LIST
1349     $HWACCEL_LIBRARY_LIST
1350     $FEATURE_LIST
1351     $LICENSE_LIST
1352     $LIBRARY_LIST
1353     $PROGRAM_LIST
1354     $SUBSYSTEM_LIST
1355     memalign_hack
1356     neon_clobber_test
1357     pic
1358     pod2man
1359     texi2html
1360     thumb
1361     valgrind_backtrace
1362     xmm_clobber_test
1363 "
1364
1365 THREADS_LIST="
1366     pthreads
1367     w32threads
1368 "
1369
1370 ATOMICS_LIST="
1371     atomics_gcc
1372     atomics_suncc
1373     atomics_win32
1374 "
1375
1376 ARCH_LIST="
1377     aarch64
1378     alpha
1379     arm
1380     avr32
1381     avr32_ap
1382     avr32_uc
1383     bfin
1384     ia64
1385     m68k
1386     mips
1387     mips64
1388     parisc
1389     ppc
1390     ppc64
1391     s390
1392     sh4
1393     sparc
1394     sparc64
1395     tilegx
1396     tilepro
1397     tomi
1398     x86
1399     x86_32
1400     x86_64
1401 "
1402
1403 ARCH_EXT_LIST_ARM="
1404     armv5te
1405     armv6
1406     armv6t2
1407     armv8
1408     neon
1409     vfp
1410     vfpv3
1411 "
1412
1413 ARCH_EXT_LIST_X86_SIMD="
1414     amd3dnow
1415     amd3dnowext
1416     avx
1417     avx2
1418     fma3
1419     fma4
1420     mmx
1421     mmxext
1422     sse
1423     sse2
1424     sse3
1425     sse4
1426     sse42
1427     ssse3
1428     xop
1429 "
1430
1431 ARCH_EXT_LIST_PPC="
1432     altivec
1433     dcbzl
1434     ldbrx
1435     power8
1436     ppc4xx
1437     vsx
1438 "
1439
1440 ARCH_EXT_LIST_X86="
1441     $ARCH_EXT_LIST_X86_SIMD
1442     cpunop
1443     i686
1444 "
1445
1446 ARCH_EXT_LIST_MIPS="
1447     loongson
1448     mips32r1
1449     mips64r1
1450     mips32r2
1451     mips64r2
1452     mips32r6
1453     mips64r6
1454 "
1455
1456 ARCH_EXT_LIST="
1457     $ARCH_EXT_LIST_ARM
1458     $ARCH_EXT_LIST_MIPS
1459     $ARCH_EXT_LIST_PPC
1460     $ARCH_EXT_LIST_X86
1461     vis
1462 "
1463
1464 ARCH_FEATURES="
1465     aligned_stack
1466     fast_64bit
1467     fast_clz
1468     fast_cmov
1469     local_aligned_8
1470     local_aligned_16
1471     local_aligned_32
1472     simd_align_16
1473 "
1474
1475 BUILTIN_LIST="
1476     atomic_cas_ptr
1477     machine_rw_barrier
1478     MemoryBarrier
1479     mm_empty
1480     rdtsc
1481     sem_timedwait
1482     sync_val_compare_and_swap
1483 "
1484 HAVE_LIST_CMDLINE="
1485     inline_asm
1486     symver
1487     yasm
1488 "
1489
1490 HAVE_LIST_PUB="
1491     bigendian
1492     fast_unaligned
1493 "
1494
1495 HEADERS_LIST="
1496     AVFoundation_AVFoundation_h
1497     alsa_asoundlib_h
1498     altivec_h
1499     arpa_inet_h
1500     cdio_paranoia_h
1501     cdio_paranoia_paranoia_h
1502     dispatch_dispatch_h
1503     dev_bktr_ioctl_bt848_h
1504     dev_bktr_ioctl_meteor_h
1505     dev_ic_bt8xx_h
1506     dev_video_bktr_ioctl_bt848_h
1507     dev_video_meteor_ioctl_meteor_h
1508     direct_h
1509     dlfcn_h
1510     d3d11_h
1511     dxva_h
1512     gsm_h
1513     io_h
1514     mach_mach_time_h
1515     machine_ioctl_bt848_h
1516     machine_ioctl_meteor_h
1517     malloc_h
1518     poll_h
1519     sndio_h
1520     soundcard_h
1521     sys_mman_h
1522     sys_param_h
1523     sys_resource_h
1524     sys_select_h
1525     sys_soundcard_h
1526     sys_time_h
1527     sys_un_h
1528     sys_videoio_h
1529     unistd_h
1530     valgrind_valgrind_h
1531     windows_h
1532     winsock2_h
1533 "
1534
1535 INTRINSICS_LIST="
1536     intrinsics_neon
1537 "
1538
1539 MATH_FUNCS="
1540     atanf
1541     atan2f
1542     cbrtf
1543     cosf
1544     exp2
1545     exp2f
1546     expf
1547     isinf
1548     isnan
1549     ldexpf
1550     llrint
1551     llrintf
1552     log2
1553     log2f
1554     log10f
1555     lrint
1556     lrintf
1557     powf
1558     rint
1559     round
1560     roundf
1561     sinf
1562     trunc
1563     truncf
1564 "
1565
1566 SYSTEM_FUNCS="
1567     aligned_malloc
1568     clock_gettime
1569     closesocket
1570     CommandLineToArgvW
1571     CoTaskMemFree
1572     CryptGenRandom
1573     dlopen
1574     fcntl
1575     flt_lim
1576     fork
1577     getaddrinfo
1578     gethrtime
1579     getopt
1580     GetProcessAffinityMask
1581     GetProcessMemoryInfo
1582     GetProcessTimes
1583     getrusage
1584     GetSystemTimeAsFileTime
1585     gettimeofday
1586     gmtime_r
1587     inet_aton
1588     isatty
1589     jack_port_get_latency_range
1590     LoadLibrary
1591     localtime_r
1592     mach_absolute_time
1593     MapViewOfFile
1594     memalign
1595     mkstemp
1596     mmap
1597     mprotect
1598     nanosleep
1599     posix_memalign
1600     sched_getaffinity
1601     SetConsoleTextAttribute
1602     setmode
1603     setrlimit
1604     Sleep
1605     strerror_r
1606     sysconf
1607     sysctl
1608     usleep
1609     VirtualAlloc
1610 "
1611
1612 TOOLCHAIN_FEATURES="
1613     as_dn_directive
1614     as_fpu_directive
1615     as_func
1616     as_object_arch
1617     asm_mod_q
1618     attribute_may_alias
1619     attribute_packed
1620     ebp_available
1621     ebx_available
1622     gnu_as
1623     ibm_asm
1624     inline_asm_labels
1625     pragma_deprecated
1626     symver_asm_label
1627     symver_gnu_asm
1628     vfp_args
1629     xform_asm
1630     xmm_clobbers
1631 "
1632
1633 TYPES_LIST="
1634     CONDITION_VARIABLE_Ptr
1635     socklen_t
1636     struct_addrinfo
1637     struct_group_source_req
1638     struct_ip_mreq_source
1639     struct_ipv6_mreq
1640     struct_pollfd
1641     struct_rusage_ru_maxrss
1642     struct_sockaddr_in6
1643     struct_sockaddr_sa_len
1644     struct_sockaddr_storage
1645     struct_v4l2_frmivalenum_discrete
1646 "
1647
1648 HAVE_LIST="
1649     $ARCH_EXT_LIST
1650     $(add_suffix _external $ARCH_EXT_LIST)
1651     $(add_suffix _inline   $ARCH_EXT_LIST)
1652     $ARCH_FEATURES
1653     $ATOMICS_LIST
1654     $BUILTIN_LIST
1655     $HAVE_LIST_CMDLINE
1656     $HAVE_LIST_PUB
1657     $HEADERS_LIST
1658     $INTRINSICS_LIST
1659     $MATH_FUNCS
1660     $SYSTEM_FUNCS
1661     $THREADS_LIST
1662     $TOOLCHAIN_FEATURES
1663     $TYPES_LIST
1664     atomics_native
1665     dos_paths
1666     dxva2_lib
1667     libc_msvcrt
1668     libdc1394_1
1669     libdc1394_2
1670     MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
1671     sdl
1672     section_data_rel_ro
1673     threads
1674     vaapi_drm
1675     vaapi_x11
1676     vdpau_x11
1677     xlib
1678 "
1679
1680 # options emitted with CONFIG_ prefix but not available on the command line
1681 CONFIG_EXTRA="
1682     aandcttables
1683     ac3dsp
1684     audio_frame_queue
1685     audiodsp
1686     blockdsp
1687     bswapdsp
1688     cabac
1689     dirac_parse
1690     dvprofile
1691     faandct
1692     faanidct
1693     fdctdsp
1694     flacdsp
1695     fmtconvert
1696     g722dsp
1697     gcrypt
1698     gmp
1699     golomb
1700     gplv3
1701     h263dsp
1702     h264chroma
1703     h264dsp
1704     h264parse
1705     h264pred
1706     h264qpel
1707     hpeldsp
1708     huffman
1709     huffyuvdsp
1710     huffyuvencdsp
1711     idctdsp
1712     iirfilter
1713     imdct15
1714     intrax8
1715     iso_media
1716     ividsp
1717     jpegtables
1718     libx262
1719     lgplv3
1720     lpc
1721     lzf
1722     me_cmp
1723     mpeg_er
1724     mpegaudio
1725     mpegaudiodsp
1726     mpegvideo
1727     mpegvideoenc
1728     mss34dsp
1729     pixblockdsp
1730     qpeldsp
1731     qsv
1732     qsvdec
1733     qsvenc
1734     rangecoder
1735     riffdec
1736     riffenc
1737     rtpdec
1738     rtpenc_chain
1739     rv34dsp
1740     sinewin
1741     snappy
1742     srtp
1743     startcode
1744     texturedsp
1745     texturedspenc
1746     tpeldsp
1747     vaapi_encode
1748     vc1dsp
1749     videodsp
1750     vp3dsp
1751     vp56dsp
1752     vp8dsp
1753     wma_freqs
1754     wmv2dsp
1755 "
1756
1757 CMDLINE_SELECT="
1758     $ARCH_EXT_LIST
1759     $CONFIG_LIST
1760     $HAVE_LIST_CMDLINE
1761     $THREADS_LIST
1762     asm
1763     cross_compile
1764     debug
1765     extra_warnings
1766     logging
1767     lto
1768     optimizations
1769     rpath
1770 "
1771
1772 PATHS_LIST="
1773     bindir
1774     datadir
1775     docdir
1776     incdir
1777     libdir
1778     mandir
1779     prefix
1780     shlibdir
1781 "
1782
1783 CMDLINE_SET="
1784     $PATHS_LIST
1785     ar
1786     arch
1787     as
1788     build_suffix
1789     cc
1790     objcc
1791     cpu
1792     cross_prefix
1793     custom_allocator
1794     dep_cc
1795     env
1796     extra_version
1797     host_cc
1798     host_cflags
1799     host_ld
1800     host_ldflags
1801     host_libs
1802     host_os
1803     ld
1804     logfile
1805     malloc_prefix
1806     nm
1807     optflags
1808     pkg_config
1809     pkg_config_flags
1810     random_seed
1811     samples
1812     sysinclude
1813     sysroot
1814     target_exec
1815     target_os
1816     target_path
1817     target_samples
1818     toolchain
1819 "
1820
1821 CMDLINE_APPEND="
1822     extra_cflags
1823     extra_objcflags
1824     host_cppflags
1825 "
1826
1827 # code dependency declarations
1828
1829 # architecture extensions
1830
1831 armv5te_deps="arm"
1832 armv6_deps="arm"
1833 armv6t2_deps="arm"
1834 armv8_deps="aarch64"
1835 neon_deps_any="aarch64 arm"
1836 intrinsics_neon_deps="neon"
1837 vfp_deps_any="aarch64 arm"
1838 vfpv3_deps="vfp"
1839
1840 map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
1841
1842 altivec_deps="ppc"
1843 ppc4xx_deps="ppc"
1844 vsx_deps="altivec"
1845 power8_deps="vsx"
1846
1847 cpunop_deps="i686"
1848 x86_64_select="i686"
1849 x86_64_suggest="fast_cmov"
1850
1851 amd3dnow_deps="mmx"
1852 amd3dnowext_deps="amd3dnow"
1853 i686_deps="x86"
1854 mmx_deps="x86"
1855 mmxext_deps="mmx"
1856 sse_deps="mmxext"
1857 sse2_deps="sse"
1858 sse3_deps="sse2"
1859 ssse3_deps="sse3"
1860 sse4_deps="ssse3"
1861 sse42_deps="sse4"
1862 avx_deps="sse42"
1863 xop_deps="avx"
1864 fma3_deps="avx"
1865 fma4_deps="avx"
1866 avx2_deps="avx"
1867
1868 mmx_external_deps="yasm"
1869 mmx_inline_deps="inline_asm"
1870 mmx_suggest="mmx_external mmx_inline"
1871
1872 for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
1873     eval dep=\$${ext}_deps
1874     eval ${ext}_external_deps='"${dep}_external"'
1875     eval ${ext}_inline_deps='"${dep}_inline"'
1876     eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
1877 done
1878
1879 aligned_stack_if_any="aarch64 ppc x86"
1880 fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1881 fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
1882 fast_unaligned_if_any="aarch64 ppc x86"
1883 simd_align_16_if_any="altivec neon sse"
1884
1885 # system capabilities
1886 symver_if_any="symver_asm_label symver_gnu_asm"
1887 valgrind_backtrace_deps="!optimizations valgrind_valgrind_h"
1888
1889 # threading support
1890 atomics_gcc_if="sync_val_compare_and_swap"
1891 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
1892 atomics_win32_if="MemoryBarrier"
1893 atomics_native_if_any="$ATOMICS_LIST"
1894 w32threads_deps="atomics_native"
1895 threads_if_any="$THREADS_LIST"
1896
1897 # subsystems
1898 dct_select="rdft"
1899 dirac_parse_select="golomb"
1900 error_resilience_select="me_cmp"
1901 faandct_deps="faan fdctdsp"
1902 faanidct_deps="faan idctdsp"
1903 h264dsp_select="startcode"
1904 intrax8_select="blockdsp idctdsp"
1905 mdct_select="fft"
1906 rdft_select="fft"
1907 me_cmp_select="fdctdsp idctdsp pixblockdsp"
1908 mpeg_er_select="error_resilience"
1909 mpegaudio_select="mpegaudiodsp"
1910 mpegaudiodsp_select="dct"
1911 mpegvideo_select="blockdsp hpeldsp idctdsp me_cmp mpeg_er videodsp"
1912 mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
1913 vc1dsp_select="h264chroma qpeldsp startcode"
1914
1915 # decoders / encoders
1916 aac_decoder_select="imdct15 mdct sinewin"
1917 aac_encoder_select="audio_frame_queue iirfilter mdct sinewin"
1918 aac_latm_decoder_select="aac_decoder aac_latm_parser"
1919 ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
1920 ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
1921 ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
1922 adpcm_g722_decoder_select="g722dsp"
1923 adpcm_g722_encoder_select="g722dsp"
1924 aic_decoder_select="golomb idctdsp"
1925 alac_encoder_select="lpc"
1926 als_decoder_select="bswapdsp"
1927 amrnb_decoder_select="lsp"
1928 amrwb_decoder_select="lsp"
1929 amv_decoder_select="sp5x_decoder"
1930 ape_decoder_select="bswapdsp"
1931 asv1_decoder_select="blockdsp bswapdsp idctdsp"
1932 asv1_encoder_select="bswapdsp fdctdsp pixblockdsp"
1933 asv2_decoder_select="blockdsp bswapdsp idctdsp"
1934 asv2_encoder_select="bswapdsp fdctdsp pixblockdsp"
1935 atrac1_decoder_select="mdct sinewin"
1936 atrac3_decoder_select="mdct"
1937 atrac3p_decoder_select="mdct sinewin"
1938 bink_decoder_select="blockdsp hpeldsp"
1939 binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
1940 binkaudio_rdft_decoder_select="mdct rdft sinewin wma_freqs"
1941 cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
1942 cllc_decoder_select="bswapdsp"
1943 comfortnoise_encoder_select="lpc"
1944 cook_decoder_select="audiodsp mdct sinewin"
1945 cscd_decoder_select="lzo"
1946 cscd_decoder_suggest="zlib"
1947 dca_decoder_select="fmtconvert mdct"
1948 dds_decoder_select="texturedsp"
1949 dnxhd_decoder_select="blockdsp idctdsp"
1950 dnxhd_encoder_select="aandcttables blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp"
1951 dvvideo_decoder_select="dvprofile idctdsp"
1952 dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
1953 dxa_decoder_deps="zlib"
1954 dxv_decoder_select="lzf texturedsp"
1955 eac3_decoder_select="ac3_decoder"
1956 eac3_encoder_select="ac3_encoder"
1957 eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
1958 eatgq_decoder_select="aandcttables idctdsp"
1959 eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp"
1960 exr_decoder_deps="zlib"
1961 ffv1_decoder_select="golomb rangecoder"
1962 ffv1_encoder_select="rangecoder"
1963 ffvhuff_decoder_select="huffyuv_decoder"
1964 ffvhuff_encoder_select="huffyuv_encoder"
1965 fic_decoder_select="golomb"
1966 flac_decoder_select="flacdsp golomb"
1967 flac_encoder_select="bswapdsp flacdsp golomb lpc"
1968 flashsv_decoder_deps="zlib"
1969 flashsv_encoder_deps="zlib"
1970 flashsv2_decoder_deps="zlib"
1971 flv_decoder_select="h263_decoder"
1972 flv_encoder_select="h263_encoder"
1973 fourxm_decoder_select="blockdsp bswapdsp"
1974 fraps_decoder_select="bswapdsp huffman"
1975 g2m_decoder_deps="zlib"
1976 g2m_decoder_select="blockdsp idctdsp jpegtables"
1977 h261_decoder_select="mpeg_er mpegvideo"
1978 h261_encoder_select="aandcttables mpegvideoenc"
1979 h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp"
1980 h263_encoder_select="aandcttables h263dsp mpegvideoenc"
1981 h263i_decoder_select="h263_decoder"
1982 h263p_encoder_select="h263_encoder"
1983 h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred h264qpel videodsp"
1984 h264_decoder_suggest="error_resilience"
1985 hap_decoder_select="snappy texturedsp"
1986 hap_encoder_deps="libsnappy"
1987 hap_encoder_select="texturedspenc"
1988 hevc_decoder_select="bswapdsp cabac golomb videodsp"
1989 huffyuv_decoder_select="bswapdsp huffyuvdsp"
1990 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp"
1991 iac_decoder_select="imc_decoder"
1992 imc_decoder_select="bswapdsp fft mdct sinewin"
1993 indeo3_decoder_select="hpeldsp"
1994 indeo4_decoder_select="ividsp"
1995 indeo5_decoder_select="ividsp"
1996 interplay_video_decoder_select="hpeldsp"
1997 jpegls_decoder_select="golomb mjpeg_decoder"
1998 jpegls_encoder_select="golomb"
1999 jv_decoder_select="blockdsp"
2000 lagarith_decoder_select="huffyuvdsp"
2001 ljpeg_encoder_select="aandcttables idctdsp jpegtables"
2002 loco_decoder_select="golomb"
2003 magicyuv_decoder_select="huffyuvdsp"
2004 mdec_decoder_select="blockdsp idctdsp mpegvideo"
2005 metasound_decoder_select="lsp mdct sinewin"
2006 mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
2007 mjpeg_decoder_select="blockdsp hpeldsp idctdsp jpegtables"
2008 mjpeg_encoder_select="aandcttables jpegtables mpegvideoenc"
2009 mjpegb_decoder_select="mjpeg_decoder"
2010 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
2011 mjpeg_vaapi_encoder_select="vaapi_encode jpegtables"
2012 mlp_decoder_select="mlp_parser"
2013 motionpixels_decoder_select="bswapdsp"
2014 mp1_decoder_select="mpegaudio"
2015 mp1float_decoder_select="mpegaudio"
2016 mp2_decoder_select="mpegaudio"
2017 mp2float_decoder_select="mpegaudio"
2018 mp3_decoder_select="mpegaudio"
2019 mp3adu_decoder_select="mpegaudio"
2020 mp3adufloat_decoder_select="mpegaudio"
2021 mp3float_decoder_select="mpegaudio"
2022 mp3on4_decoder_select="mpegaudio"
2023 mp3on4float_decoder_select="mpegaudio"
2024 mpc7_decoder_select="bswapdsp mpegaudiodsp"
2025 mpc8_decoder_select="mpegaudiodsp"
2026 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
2027 mpeg_xvmc_decoder_select="mpeg2video_decoder"
2028 mpeg1video_decoder_select="error_resilience mpeg_er mpegvideo"
2029 mpeg1video_encoder_select="aandcttables mpegvideoenc"
2030 mpeg2video_decoder_select="error_resilience mpeg_er mpegvideo"
2031 mpeg2video_encoder_select="aandcttables mpegvideoenc"
2032 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
2033 mpeg4_encoder_select="h263_encoder"
2034 msa1_decoder_select="mss34dsp"
2035 msmpeg4v1_decoder_select="h263_decoder"
2036 msmpeg4v2_decoder_select="h263_decoder"
2037 msmpeg4v2_encoder_select="h263_encoder"
2038 msmpeg4v3_decoder_select="h263_decoder"
2039 msmpeg4v3_encoder_select="h263_encoder"
2040 mss2_decoder_select="error_resilience mpeg_er mpegvideo vc1_decoder"
2041 mts2_decoder_select="mss34dsp"
2042 mxpeg_decoder_select="mjpeg_decoder"
2043 nellymoser_decoder_select="mdct sinewin"
2044 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
2045 nuv_decoder_select="idctdsp lzo"
2046 on2avc_decoder_select="mdct"
2047 opus_decoder_deps="avresample"
2048 opus_decoder_select="imdct15"
2049 png_decoder_deps="zlib"
2050 png_encoder_deps="zlib"
2051 png_encoder_select="huffyuvencdsp"
2052 prores_decoder_select="idctdsp"
2053 prores_encoder_select="fdctdsp"
2054 qcelp_decoder_select="lsp"
2055 qdm2_decoder_select="mdct rdft mpegaudiodsp"
2056 ra_144_encoder_select="audio_frame_queue lpc"
2057 ralf_decoder_select="golomb"
2058 rscc_decoder_deps="zlib"
2059 rv10_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
2060 rv10_encoder_select="h263_encoder"
2061 rv20_decoder_select="error_resilience h263_decoder h263dsp mpeg_er"
2062 rv20_encoder_select="h263_encoder"
2063 rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
2064 rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpeg_er mpegvideo rv34dsp videodsp"
2065 screenpresso_decoder_deps="zlib"
2066 shorten_decoder_select="golomb"
2067 sipr_decoder_select="lsp"
2068 sp5x_decoder_select="mjpeg_decoder"
2069 svq1_decoder_select="hpeldsp"
2070 svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
2071 svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp videodsp"
2072 svq3_decoder_suggest="zlib"
2073 tak_decoder_select="audiodsp"
2074 tdsc_decoder_deps="zlib"
2075 tdsc_decoder_select="mjpeg_decoder"
2076 theora_decoder_select="vp3_decoder"
2077 thp_decoder_select="mjpeg_decoder"
2078 tiff_decoder_suggest="zlib"
2079 tiff_encoder_suggest="zlib"
2080 truehd_decoder_select="mlp_decoder"
2081 truemotion2_decoder_select="bswapdsp"
2082 truespeech_decoder_select="bswapdsp"
2083 tscc_decoder_deps="zlib"
2084 txd_decoder_select="texturedsp"
2085 twinvq_decoder_select="mdct lsp sinewin"
2086 utvideo_decoder_select="bswapdsp"
2087 utvideo_encoder_select="bswapdsp huffman huffyuvencdsp"
2088 vble_decoder_select="huffyuvdsp"
2089 vc1_decoder_select="blockdsp error_resilience h263_decoder h264qpel intrax8 mpeg_er mpegvideo vc1dsp"
2090 vc1image_decoder_select="vc1_decoder"
2091 vorbis_decoder_select="mdct"
2092 vorbis_encoder_select="mdct"
2093 vp3_decoder_select="hpeldsp vp3dsp videodsp"
2094 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp"
2095 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp"
2096 vp6a_decoder_select="vp6_decoder"
2097 vp6f_decoder_select="vp6_decoder"
2098 vp7_decoder_select="h264pred videodsp vp8dsp"
2099 vp8_decoder_select="h264pred videodsp vp8dsp"
2100 vp9_decoder_select="videodsp"
2101 webp_decoder_select="vp8_decoder"
2102 wmapro_decoder_select="mdct sinewin wma_freqs"
2103 wmav1_decoder_select="mdct sinewin wma_freqs"
2104 wmav1_encoder_select="mdct sinewin wma_freqs"
2105 wmav2_decoder_select="mdct sinewin wma_freqs"
2106 wmav2_encoder_select="mdct sinewin wma_freqs"
2107 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
2108 wmv1_decoder_select="h263_decoder"
2109 wmv1_encoder_select="h263_encoder"
2110 wmv2_decoder_select="blockdsp error_resilience h263_decoder idctdsp intrax8 videodsp wmv2dsp"
2111 wmv2_encoder_select="h263_encoder wmv2dsp"
2112 wmv3_decoder_select="vc1_decoder"
2113 wmv3image_decoder_select="wmv3_decoder"
2114 zerocodec_decoder_deps="zlib"
2115 zlib_decoder_deps="zlib"
2116 zlib_encoder_deps="zlib"
2117 zmbv_decoder_deps="zlib"
2118 zmbv_encoder_deps="zlib"
2119
2120 # hardware accelerators
2121 d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder"
2122 dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode"
2123 vaapi_deps="va_va_h"
2124 vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
2125 vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore"
2126 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
2127
2128 h263_vaapi_hwaccel_deps="vaapi"
2129 h263_vaapi_hwaccel_select="h263_decoder"
2130 h264_d3d11va_hwaccel_deps="d3d11va"
2131 h264_d3d11va_hwaccel_select="h264_decoder"
2132 h264_dxva2_hwaccel_deps="dxva2"
2133 h264_dxva2_hwaccel_select="h264_decoder"
2134 h264_mmal_decoder_deps="mmal"
2135 h264_mmal_decoder_select="mmal"
2136 h264_mmal_hwaccel_deps="mmal"
2137 h264_omx_encoder_deps="omx"
2138 h264_qsv_hwaccel_deps="libmfx"
2139 h264_vaapi_hwaccel_deps="vaapi"
2140 h264_vaapi_hwaccel_select="h264_decoder"
2141 h264_vda_hwaccel_deps="vda"
2142 h264_vda_hwaccel_select="h264_decoder"
2143 h264_vda_old_hwaccel_deps="vda"
2144 h264_vda_old_hwaccel_select="h264_decoder"
2145 h264_vdpau_hwaccel_deps="vdpau"
2146 h264_vdpau_hwaccel_select="h264_decoder"
2147 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
2148 hevc_d3d11va_hwaccel_select="hevc_decoder"
2149 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
2150 hevc_dxva2_hwaccel_select="hevc_decoder"
2151 hevc_qsv_hwaccel_deps="libmfx"
2152 hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
2153 hevc_vdpau_hwaccel_select="hevc_decoder"
2154 mpeg1_vdpau_hwaccel_deps="vdpau"
2155 mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
2156 mpeg2_d3d11va_hwaccel_deps="d3d11va"
2157 mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder"
2158 mpeg2_dxva2_hwaccel_deps="dxva2"
2159 mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
2160 mpeg2_mmal_decoder_deps="mmal"
2161 mpeg2_mmal_decoder_select="mmal"
2162 mpeg2_mmal_hwaccel_deps="mmal"
2163 mpeg2_qsv_hwaccel_deps="libmfx"
2164 mpeg2_vaapi_hwaccel_deps="vaapi"
2165 mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
2166 mpeg2_vdpau_hwaccel_deps="vdpau"
2167 mpeg2_vdpau_hwaccel_select="mpeg2video_decoder"
2168 mpeg4_omx_encoder_deps="omx"
2169 mpeg4_vaapi_hwaccel_deps="vaapi"
2170 mpeg4_vaapi_hwaccel_select="mpeg4_decoder"
2171 mpeg4_vdpau_hwaccel_deps="vdpau"
2172 mpeg4_vdpau_hwaccel_select="mpeg4_decoder"
2173 vc1_d3d11va_hwaccel_deps="d3d11va"
2174 vc1_d3d11va_hwaccel_select="vc1_decoder"
2175 vc1_dxva2_hwaccel_deps="dxva2"
2176 vc1_dxva2_hwaccel_select="vc1_decoder"
2177 vc1_mmal_decoder_deps="mmal"
2178 vc1_mmal_decoder_select="mmal"
2179 vc1_mmal_hwaccel_deps="mmal"
2180 vc1_vaapi_hwaccel_deps="vaapi"
2181 vc1_vaapi_hwaccel_select="vc1_decoder"
2182 vc1_vdpau_hwaccel_deps="vdpau"
2183 vc1_vdpau_hwaccel_select="vc1_decoder"
2184 wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
2185 wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
2186 wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
2187 wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
2188
2189 # hardware-accelerated codecs
2190 nvenc_deps_any="dlopen LoadLibrary"
2191 nvenc_extralibs='$ldl'
2192 omx_deps="dlopen pthreads"
2193 omx_extralibs='$ldl'
2194 qsvdec_select="qsv"
2195 qsvenc_select="qsv"
2196 vaapi_encode_deps="vaapi"
2197
2198 hwupload_cuda_filter_deps="cuda"
2199 scale_npp_filter_deps="cuda libnpp"
2200
2201 h264_nvenc_encoder_deps="nvenc"
2202 h264_qsv_decoder_deps="libmfx"
2203 h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel"
2204 h264_qsv_encoder_deps="libmfx"
2205 h264_qsv_encoder_select="qsvenc"
2206 h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
2207 h264_vaapi_encoder_select="vaapi_encode golomb"
2208
2209 hevc_nvenc_encoder_deps="nvenc"
2210 hevc_qsv_decoder_deps="libmfx"
2211 hevc_qsv_encoder_deps="libmfx"
2212 hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser hevc_qsv_hwaccel qsvdec"
2213 hevc_qsv_encoder_select="qsvenc"
2214 hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
2215 hevc_vaapi_encoder_select="vaapi_encode golomb"
2216 mpeg2_qsv_decoder_deps="libmfx"
2217 mpeg2_qsv_decoder_select="qsvdec mpeg2_qsv_hwaccel mpegvideo_parser"
2218 mpeg2_qsv_encoder_deps="libmfx"
2219 mpeg2_qsv_encoder_select="qsvenc"
2220
2221 nvenc_h264_encoder_deps="nvenc"
2222 nvenc_hevc_encoder_deps="nvenc"
2223
2224 # parsers
2225 h264_parser_select="golomb h264dsp h264parse"
2226 hevc_parser_select="golomb"
2227 mpegvideo_parser_select="mpegvideo"
2228 mpeg4video_parser_select="error_resilience h263dsp mpegvideo qpeldsp"
2229 vc1_parser_select="vc1dsp"
2230
2231 # bitstream_filters
2232 mjpeg2jpeg_bsf_select="jpegtables"
2233
2234 # external libraries
2235 libdcadec_decoder_deps="libdcadec"
2236 libfaac_encoder_deps="libfaac"
2237 libfaac_encoder_select="audio_frame_queue"
2238 libfdk_aac_decoder_deps="libfdk_aac"
2239 libfdk_aac_encoder_deps="libfdk_aac"
2240 libfdk_aac_encoder_select="audio_frame_queue"
2241 libgsm_decoder_deps="libgsm"
2242 libgsm_encoder_deps="libgsm"
2243 libgsm_ms_decoder_deps="libgsm"
2244 libgsm_ms_encoder_deps="libgsm"
2245 libilbc_decoder_deps="libilbc"
2246 libilbc_encoder_deps="libilbc"
2247 libkvazaar_encoder_deps="libkvazaar"
2248 libmp3lame_encoder_deps="libmp3lame"
2249 libmp3lame_encoder_select="audio_frame_queue"
2250 libopencore_amrnb_decoder_deps="libopencore_amrnb"
2251 libopencore_amrnb_encoder_deps="libopencore_amrnb"
2252 libopencore_amrnb_encoder_select="audio_frame_queue"
2253 libopencore_amrwb_decoder_deps="libopencore_amrwb"
2254 libopenh264_decoder_deps="libopenh264"
2255 libopenh264_decoder_select="h264_mp4toannexb_bsf"
2256 libopenh264_encoder_deps="libopenh264"
2257 libopenjpeg_decoder_deps="libopenjpeg"
2258 libopenjpeg_encoder_deps="libopenjpeg"
2259 libopus_decoder_deps="libopus"
2260 libopus_encoder_deps="libopus"
2261 libopus_encoder_select="audio_frame_queue"
2262 libschroedinger_decoder_deps="libschroedinger"
2263 libschroedinger_encoder_deps="libschroedinger"
2264 libspeex_decoder_deps="libspeex"
2265 libspeex_encoder_deps="libspeex"
2266 libspeex_encoder_select="audio_frame_queue"
2267 libtheora_encoder_deps="libtheora"
2268 libtwolame_encoder_deps="libtwolame"
2269 libvo_aacenc_encoder_deps="libvo_aacenc"
2270 libvo_aacenc_encoder_select="audio_frame_queue"
2271 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
2272 libvorbis_encoder_deps="libvorbis"
2273 libvorbis_encoder_select="audio_frame_queue"
2274 libvpx_vp8_decoder_deps="libvpx"
2275 libvpx_vp8_encoder_deps="libvpx"
2276 libvpx_vp9_decoder_deps="libvpx"
2277 libvpx_vp9_encoder_deps="libvpx"
2278 libwavpack_encoder_deps="libwavpack"
2279 libwebp_encoder_deps="libwebp"
2280 libx262_encoder_deps="libx262"
2281 libx264_encoder_deps="libx264"
2282 libx265_encoder_deps="libx265"
2283 libxavs_encoder_deps="libxavs"
2284 libxvid_encoder_deps="libxvid"
2285
2286 # demuxers / muxers
2287 ac3_demuxer_select="ac3_parser"
2288 asf_demuxer_select="riffdec"
2289 asf_muxer_select="riffenc"
2290 asf_stream_muxer_select="asf_muxer"
2291 avi_demuxer_select="iso_media riffdec"
2292 avi_muxer_select="riffenc"
2293 avisynth_demuxer_deps="avisynth"
2294 avisynth_demuxer_select="riffdec"
2295 caf_demuxer_select="iso_media riffdec"
2296 dash_muxer_select="mp4_muxer"
2297 dirac_demuxer_select="dirac_parser"
2298 dv_demuxer_select="dvprofile"
2299 dv_muxer_select="dvprofile"
2300 dxa_demuxer_select="riffdec"
2301 eac3_demuxer_select="ac3_parser"
2302 f4v_muxer_select="mov_muxer"
2303 flac_demuxer_select="flac_parser"
2304 hds_muxer_select="flv_muxer"
2305 hls_muxer_select="mpegts_muxer"
2306 ipod_muxer_select="mov_muxer"
2307 ismv_muxer_select="mov_muxer"
2308 matroska_audio_muxer_select="matroska_muxer"
2309 matroska_demuxer_select="iso_media riffdec"
2310 matroska_demuxer_suggest="bzlib lzo zlib"
2311 matroska_muxer_select="iso_media riffenc"
2312 mmf_muxer_select="riffenc"
2313 mov_demuxer_select="iso_media riffdec"
2314 mov_demuxer_suggest="zlib"
2315 mov_muxer_select="iso_media riffenc rtpenc_chain"
2316 mp3_demuxer_select="mpegaudio_parser"
2317 mp4_muxer_select="mov_muxer"
2318 mpegts_demuxer_select="iso_media"
2319 mpegts_muxer_select="adts_muxer latm_muxer"
2320 mpegtsraw_demuxer_select="mpegts_demuxer"
2321 mxf_d10_muxer_select="mxf_muxer"
2322 nut_muxer_select="riffenc"
2323 nuv_demuxer_select="riffdec"
2324 oga_muxer_select="ogg_muxer"
2325 ogg_demuxer_select="dirac_parse"
2326 opus_muxer_select="ogg_muxer"
2327 psp_muxer_select="mov_muxer"
2328 rtp_demuxer_select="sdp_demuxer"
2329 rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
2330 rtsp_demuxer_select="http_protocol rtpdec"
2331 rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
2332 sap_demuxer_select="sdp_demuxer"
2333 sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
2334 sdp_demuxer_select="rtpdec"
2335 smoothstreaming_muxer_select="ismv_muxer"
2336 spdif_muxer_select="aac_parser"
2337 spx_muxer_select="ogg_muxer"
2338 swf_demuxer_suggest="zlib"
2339 tak_demuxer_select="tak_parser"
2340 tg2_muxer_select="mov_muxer"
2341 tgp_muxer_select="mov_muxer"
2342 w64_demuxer_select="wav_demuxer"
2343 wav_demuxer_select="riffdec"
2344 wav_muxer_select="riffenc"
2345 webm_muxer_select="iso_media riffenc"
2346 webm_muxer_suggest="libopus_encoder libvorbis_encoder libvpx_vp8_encoder libvpx_vp9_encoder"
2347 wtv_demuxer_select="mpegts_demuxer riffdec"
2348 xmv_demuxer_select="riffdec"
2349 xwma_demuxer_select="riffdec"
2350
2351 # indevs / outdevs
2352 alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
2353 alsa_outdev_deps="alsa_asoundlib_h"
2354 avfoundation_indev_deps="AVFoundation_AVFoundation_h"
2355 bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
2356 dv1394_indev_deps="dv1394"
2357 dv1394_indev_select="dv_demuxer"
2358 fbdev_indev_deps="linux_fb_h"
2359 jack_indev_deps="jack_jack_h"
2360 jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
2361 libcdio_indev_deps="libcdio"
2362 libdc1394_indev_deps="libdc1394"
2363 oss_indev_deps_any="soundcard_h sys_soundcard_h"
2364 oss_outdev_deps_any="soundcard_h sys_soundcard_h"
2365 pulse_indev_deps="libpulse"
2366 sndio_indev_deps="sndio_h"
2367 sndio_outdev_deps="sndio_h"
2368 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
2369 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
2370 vfwcap_indev_extralibs="-lavicap32"
2371 xcbgrab_indev_deps="libxcb"
2372
2373 # protocols
2374 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
2375 ffrtmpcrypt_protocol_deps_any="gcrypt gmp openssl"
2376 ffrtmpcrypt_protocol_select="tcp_protocol"
2377 ffrtmphttp_protocol_deps="!librtmp_protocol"
2378 ffrtmphttp_protocol_select="http_protocol"
2379 gopher_protocol_select="network"
2380 http_protocol_select="tcp_protocol"
2381 httpproxy_protocol_select="tcp_protocol"
2382 https_protocol_select="tls_protocol"
2383 icecast_protocol_select="http_protocol"
2384 librtmp_protocol_deps="librtmp"
2385 librtmpe_protocol_deps="librtmp"
2386 librtmps_protocol_deps="librtmp"
2387 librtmpt_protocol_deps="librtmp"
2388 librtmpte_protocol_deps="librtmp"
2389 mmsh_protocol_select="http_protocol"
2390 mmst_protocol_select="network"
2391 rtmp_protocol_deps="!librtmp_protocol"
2392 rtmp_protocol_select="tcp_protocol"
2393 rtmpe_protocol_select="ffrtmpcrypt_protocol"
2394 rtmps_protocol_deps="!librtmp_protocol"
2395 rtmps_protocol_select="tls_protocol"
2396 rtmpt_protocol_select="ffrtmphttp_protocol"
2397 rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
2398 rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
2399 rtp_protocol_select="udp_protocol"
2400 sctp_protocol_deps="struct_sctp_event_subscribe"
2401 sctp_protocol_select="network"
2402 srtp_protocol_select="rtp_protocol srtp"
2403 tcp_protocol_select="network"
2404 tls_gnutls_protocol_deps="gnutls"
2405 tls_gnutls_protocol_select="tcp_protocol"
2406 tls_openssl_protocol_deps="openssl !tls_gnutls_protocol"
2407 tls_openssl_protocol_select="tcp_protocol"
2408 tls_protocol_deps_any="tls_gnutls_protocol tls_openssl_protocol"
2409 udp_protocol_select="network"
2410 unix_protocol_deps="sys_un_h"
2411 unix_protocol_select="network"
2412
2413 # filters
2414 blackframe_filter_deps="gpl"
2415 boxblur_filter_deps="gpl"
2416 bs2b_filter_deps="libbs2b"
2417 cropdetect_filter_deps="gpl"
2418 deinterlace_qsv_filter_deps="libmfx"
2419 delogo_filter_deps="gpl"
2420 drawtext_filter_deps="libfreetype"
2421 frei0r_filter_deps="frei0r dlopen"
2422 frei0r_filter_extralibs='$ldl'
2423 frei0r_src_filter_deps="frei0r dlopen"
2424 frei0r_src_filter_extralibs='$ldl'
2425 hqdn3d_filter_deps="gpl"
2426 interlace_filter_deps="gpl"
2427 ocv_filter_deps="libopencv"
2428 resample_filter_deps="avresample"
2429 scale_filter_deps="swscale"
2430 scale_qsv_filter_deps="libmfx"
2431 scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
2432
2433 # examples
2434 avcodec_example_deps="avcodec avutil"
2435 filter_audio_example_deps="avfilter avutil"
2436 metadata_example_deps="avformat avutil"
2437 output_example_deps="avcodec avformat avutil swscale"
2438 qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder vaapi_x11"
2439 transcode_aac_example_deps="avcodec avformat avresample"
2440
2441 # libraries, in linking order
2442 avcodec_deps="avutil"
2443 avdevice_deps="avformat avcodec avutil"
2444 avfilter_deps="avutil"
2445 avformat_deps="avcodec avutil"
2446 avresample_deps="avutil"
2447 swscale_deps="avutil"
2448
2449 # programs
2450 avconv_deps="avcodec avfilter avformat avresample swscale"
2451 avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_filter
2452                fps_filter null_filter resample_filter scale_filter
2453                trim_filter"
2454 avplay_deps="avcodec avfilter avformat avresample sdl"
2455 avplay_libs='$sdl_libs'
2456 avplay_select="rdft format_filter transpose_filter hflip_filter vflip_filter"
2457 avprobe_deps="avcodec avformat"
2458
2459 # documentation
2460 pod2man_deps="doc"
2461 texi2html_deps="doc"
2462
2463 # default parameters
2464
2465 logfile="config.log"
2466
2467 # installation paths
2468 prefix_default="/usr/local"
2469 bindir_default='${prefix}/bin'
2470 datadir_default='${prefix}/share/avconv'
2471 docdir_default='${prefix}/share/doc/libav'
2472 incdir_default='${prefix}/include'
2473 libdir_default='${prefix}/lib'
2474 mandir_default='${prefix}/share/man'
2475 shlibdir_default="$libdir_default"
2476
2477 # toolchain
2478 ar_default="ar"
2479 cc_default="gcc"
2480 host_cc_default="gcc"
2481 cp_f="cp -f"
2482 ln_s="ln -s -f"
2483 nm_default="nm -g"
2484 objformat="elf"
2485 pkg_config_default=pkg-config
2486 ranlib="ranlib"
2487 strip="strip"
2488 version_script='--version-script'
2489 yasmexe="yasm"
2490
2491 # machine
2492 arch_default=$(uname -m)
2493 cpu="generic"
2494 intrinsics="none"
2495
2496 # OS
2497 target_os_default=$(tolower $(uname -s))
2498 host_os=$target_os_default
2499
2500 # configurable options
2501 enable $EXAMPLE_LIST $LIBRARY_LIST $PROGRAM_LIST
2502
2503 enable asm
2504 enable debug
2505 enable doc
2506 enable faan faandct faanidct
2507 enable optimizations
2508 enable safe_bitstream_reader
2509 enable static
2510 enable swscale_alpha
2511 enable valgrind_backtrace
2512
2513 # By default, enable only those hwaccels that have no external dependencies.
2514 enable d3d11va dxva2 vda vdpau
2515
2516 # build settings
2517 SHFLAGS='-shared -Wl,-soname,$$(@F)'
2518 LIBPREF="lib"
2519 LIBSUF=".a"
2520 FULLNAME='$(NAME)$(BUILDSUF)'
2521 LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
2522 SLIBPREF="lib"
2523 SLIBSUF=".so"
2524 SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
2525 SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
2526 SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
2527 LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
2528 SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
2529 SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
2530 VERSION_SCRIPT_POSTPROCESS_CMD="cat"
2531
2532 asflags_filter=echo
2533 cflags_filter=echo
2534 ldflags_filter=echo
2535
2536 AS_C='-c'
2537 AS_O='-o $@'
2538 CC_C='-c'
2539 CC_E='-E -o $@'
2540 CC_O='-o $@'
2541 OBJCC_C='-c'
2542 OBJCC_E='-E -o $@'
2543 OBJCC_O='-o $@'
2544 LD_O='-o $@'
2545 LD_LIB='-l%'
2546 LD_PATH='-L'
2547 HOSTCC_C='-c'
2548 HOSTCC_E='-E -o $@'
2549 HOSTCC_O='-o $@'
2550 HOSTLD_O='-o $@'
2551
2552 host_libs='-lm'
2553 host_cflags_filter=echo
2554 host_ldflags_filter=echo
2555
2556 target_path='$(CURDIR)'
2557
2558 # since the object filename is not given with the -MM flag, the compiler
2559 # is only able to print the basename, and we must add the path ourselves
2560 DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
2561 DEPFLAGS='-MM'
2562
2563 # find source path
2564 if test -f configure; then
2565     source_path=.
2566 else
2567     source_path=$(cd $(dirname "$0"); pwd)
2568     echo "$source_path" | grep -q '[[:blank:]]' &&
2569         die "Out of tree builds are impossible with whitespace in source path."
2570     test -e "$source_path/config.h" &&
2571         die "Out of tree builds are impossible with config.h in source dir."
2572 fi
2573
2574 for v in "$@"; do
2575     r=${v#*=}
2576     l=${v%"$r"}
2577     r=$(sh_quote "$r")
2578     LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
2579 done
2580
2581 find_things(){
2582     thing=$1
2583     pattern=$2
2584     file=$source_path/$3
2585     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
2586 }
2587
2588 ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
2589 DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
2590 HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
2591 PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
2592 MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
2593 DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
2594 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
2595 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
2596 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
2597
2598 find_things_extern(){
2599     thing=$1
2600     pattern=$2
2601     file=$source_path/$3
2602     sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
2603 }
2604
2605 BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c)
2606 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c)
2607
2608 ALL_COMPONENTS="
2609     $BSF_LIST
2610     $DECODER_LIST
2611     $DEMUXER_LIST
2612     $ENCODER_LIST
2613     $FILTER_LIST
2614     $HWACCEL_LIST
2615     $INDEV_LIST
2616     $MUXER_LIST
2617     $OUTDEV_LIST
2618     $PARSER_LIST
2619     $PROTOCOL_LIST
2620 "
2621
2622 for n in $COMPONENT_LIST; do
2623     v=$(toupper ${n%s})_LIST
2624     eval enable \$$v
2625     eval ${n}_if_any="\$$v"
2626 done
2627
2628 enable $ARCH_EXT_LIST
2629
2630 die_unknown(){
2631     echo "Unknown option \"$1\"."
2632     echo "See $0 --help for available options."
2633     exit 1
2634 }
2635
2636 print_3_columns() {
2637     printf "%-25s %-25s %-25s\n" $(cat | tr ' ' '\n' | sort)
2638 }
2639
2640 show_list() {
2641     suffix=_$1
2642     shift
2643     echo $* | sed s/$suffix//g | print_3_columns
2644     exit 0
2645 }
2646
2647 rand_list(){
2648     IFS=', '
2649     set -- $*
2650     unset IFS
2651     for thing; do
2652         comp=${thing%:*}
2653         prob=${thing#$comp}
2654         prob=${prob#:}
2655         is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
2656         echo "prob ${prob:-0.5}"
2657         printf '%s\n' $comp
2658     done
2659 }
2660
2661 do_random(){
2662     action=$1
2663     shift
2664     random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
2665     $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
2666 }
2667
2668 for opt do
2669     optval="${opt#*=}"
2670     case "$opt" in
2671         --extra-ldflags=*)
2672             add_ldflags $optval
2673         ;;
2674         --extra-ldexeflags=*)
2675             add_ldexeflags $optval
2676         ;;
2677         --extra-libs=*)
2678             add_extralibs $optval
2679         ;;
2680         --disable-devices)
2681             disable $INDEV_LIST $OUTDEV_LIST
2682         ;;
2683         --enable-debug=*)
2684             debuglevel="$optval"
2685         ;;
2686         --disable-programs)
2687             disable $PROGRAM_LIST
2688         ;;
2689         --disable-everything)
2690             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2691         ;;
2692         --disable-all)
2693             map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
2694             disable $LIBRARY_LIST $PROGRAM_LIST doc
2695         ;;
2696         --enable-random|--disable-random)
2697             action=${opt%%-random}
2698             do_random ${action#--} $COMPONENT_LIST
2699         ;;
2700         --enable-random=*|--disable-random=*)
2701             action=${opt%%-random=*}
2702             do_random ${action#--} $optval
2703         ;;
2704         --enable-*=*|--disable-*=*)
2705             eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
2706             is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
2707             eval list=\$$(toupper $thing)_LIST
2708             name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
2709             $action $(filter "$name" $list)
2710         ;;
2711         --enable-avserver|--disable-avserver*)
2712             warn "avserver has been removed, the ${opt} option is only"\
2713                  "provided for compatibility and will be removed in the future"
2714         ;;
2715         --enable-?*|--disable-?*)
2716             eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
2717             if is_in $option $COMPONENT_LIST; then
2718                 test $action = disable && action=unset
2719                 eval $action \$$(toupper ${option%s})_LIST
2720             elif is_in $option $CMDLINE_SELECT; then
2721                 $action $option
2722             else
2723                 die_unknown $opt
2724             fi
2725         ;;
2726         --list-*)
2727             NAME="${opt#--list-}"
2728             is_in $NAME $COMPONENT_LIST || die_unknown $opt
2729             NAME=${NAME%s}
2730             eval show_list $NAME \$$(toupper $NAME)_LIST
2731         ;;
2732         --help|-h) show_help
2733         ;;
2734         *)
2735             optname="${opt%%=*}"
2736             optname="${optname#--}"
2737             optname=$(echo "$optname" | sed 's/-/_/g')
2738             if is_in $optname $CMDLINE_SET; then
2739                 eval $optname='$optval'
2740             elif is_in $optname $CMDLINE_APPEND; then
2741                 append $optname "$optval"
2742             else
2743                 die_unknown $opt
2744             fi
2745         ;;
2746     esac
2747 done
2748
2749 for e in $env; do
2750     eval "export $e"
2751 done
2752
2753 disabled logging && logfile=/dev/null
2754
2755 # Disable all the library-specific components if the library itself
2756 # is disabled, see AVCODEC_LIST and following _LIST variables.
2757
2758 disable_components(){
2759     disabled ${1} && disable $(
2760         eval components="\$$(toupper ${1})_COMPONENTS"
2761         map 'eval echo \${$(toupper ${v%s})_LIST}' $components
2762     )
2763 }
2764
2765 map 'disable_components $v' $LIBRARY_LIST
2766
2767 echo "# $0 $LIBAV_CONFIGURATION" > $logfile
2768 set >> $logfile
2769
2770 case "$toolchain" in
2771     *-asan)
2772         cc_default="${toolchain%-asan}"
2773         add_cflags  -fsanitize=address
2774         add_ldflags -fsanitize=address
2775     ;;
2776     *-msan)
2777         cc_default="${toolchain%-msan}"
2778         add_cflags  -fsanitize=memory -fsanitize-memory-track-origins
2779         add_ldflags -fsanitize=memory
2780     ;;
2781     *-tsan)
2782         cc_default="${toolchain%-tsan}"
2783         add_cflags  -fsanitize=thread -pie
2784         add_ldflags -fsanitize=thread -pie
2785         case "$toolchain" in
2786             gcc-tsan)
2787                 add_cflags  -fPIC
2788                 add_ldflags -fPIC
2789                 ;;
2790         esac
2791     ;;
2792     *-usan)
2793         cc_default="${toolchain%-usan}"
2794         add_cflags  -fsanitize=undefined
2795         add_ldflags -fsanitize=undefined
2796         case "$toolchain" in
2797             clang-usan)
2798                 add_cflags -O1
2799                 ;;
2800         esac
2801     ;;
2802     valgrind-*)
2803         target_exec_default="valgrind"
2804         case "$toolchain" in
2805             valgrind-massif)
2806                 target_exec_args="--alloc-fn=av_malloc --alloc-fn=av_mallocz"
2807                 ;;
2808             valgrind-memcheck)
2809                 target_exec_args="--track-origins=yes --leak-check=full"
2810                 ;;
2811         esac
2812     ;;
2813     msvc)
2814         # Check whether the current MSVC version needs the C99 converter.
2815         # From MSVC 2013 (compiler major version 18) onwards, it does actually
2816         # support enough of C99 to build libav. Default to the new
2817         # behaviour if the regexp was unable to match anything, since this
2818         # successfully parses the version number of existing supported
2819         # versions that require the converter (MSVC 2010 and 2012).
2820         cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
2821         if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
2822             cc_default="cl"
2823         else
2824             cc_default="c99wrap cl"
2825         fi
2826         ld_default="$source_path/compat/windows/mslink"
2827         nm_default="dumpbin -symbols"
2828         ar_default="lib"
2829         case "$arch" in
2830         arm*)
2831             as_default="armasm"
2832             ;;
2833         esac
2834         target_os_default="win32"
2835         # Use a relative path for TMPDIR. This makes sure all the
2836         # ffconf temp files are written with a relative path, avoiding
2837         # issues with msys/win32 path conversion for MSVC parameters
2838         # such as -Fo<file> or -out:<file>.
2839         TMPDIR=.
2840     ;;
2841     icl)
2842         cc_default="icl"
2843         ld_default="xilink"
2844         nm_default="dumpbin -symbols"
2845         ar_default="xilib"
2846         target_os_default="win32"
2847         TMPDIR=.
2848     ;;
2849     gcov)
2850         add_cflags  -fprofile-arcs -ftest-coverage
2851         add_ldflags -fprofile-arcs -ftest-coverage
2852     ;;
2853     llvm-cov)
2854         add_cflags -fprofile-arcs -ftest-coverage
2855         add_ldflags --coverage
2856     ;;
2857     hardened)
2858         add_cppflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
2859         add_cflags   -fno-strict-overflow -fstack-protector-all
2860         add_ldflags  -Wl,-z,relro -Wl,-z,now
2861     ;;
2862     ?*)
2863         die "Unknown toolchain $toolchain"
2864     ;;
2865 esac
2866
2867 test -n "$cross_prefix" && enable cross_compile
2868
2869 if enabled cross_compile; then
2870     test -n "$arch" && test -n "$target_os" ||
2871         die "Must specify target arch and OS when cross-compiling"
2872 fi
2873
2874 ar_default="${cross_prefix}${ar_default}"
2875 cc_default="${cross_prefix}${cc_default}"
2876 occ_default="${cross_prefix}${occ_default}"
2877 nm_default="${cross_prefix}${nm_default}"
2878 pkg_config_default="${cross_prefix}${pkg_config_default}"
2879 ranlib="${cross_prefix}${ranlib}"
2880 strip="${cross_prefix}${strip}"
2881
2882 sysinclude_default="${sysroot}/usr/include"
2883
2884 set_default arch cc pkg_config sysinclude target_exec target_os
2885 enabled cross_compile || host_cc_default=$cc
2886 set_default host_cc
2887
2888 if ! $pkg_config --version >/dev/null 2>&1; then
2889     warn "$pkg_config not found, library detection may fail."
2890     pkg_config=false
2891 fi
2892
2893 exesuf() {
2894     case $1 in
2895         mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
2896     esac
2897 }
2898
2899 EXESUF=$(exesuf $target_os)
2900 HOSTEXESUF=$(exesuf $host_os)
2901
2902 # set temporary file name
2903 : ${TMPDIR:=$TEMPDIR}
2904 : ${TMPDIR:=$TMP}
2905 : ${TMPDIR:=/tmp}
2906
2907 if ! check_cmd mktemp -u XXXXXX; then
2908     # simple replacement for missing mktemp
2909     # NOT SAFE FOR GENERAL USE
2910     mktemp(){
2911         echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
2912     }
2913 fi
2914
2915 tmpfile(){
2916     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
2917         (set -C; exec > $tmp) 2>/dev/null ||
2918         die "Unable to create temporary file in $TMPDIR."
2919     append TMPFILES $tmp
2920     eval $1=$tmp
2921 }
2922
2923 trap 'rm -f -- $TMPFILES' EXIT
2924
2925 tmpfile TMPASM .asm
2926 tmpfile TMPC   .c
2927 tmpfile TMPE   $EXESUF
2928 tmpfile TMPH   .h
2929 tmpfile TMPO   .o
2930 tmpfile TMPS   .S
2931 tmpfile TMPSH  .sh
2932 tmpfile TMPV   .ver
2933
2934 unset -f mktemp
2935
2936 chmod +x $TMPE
2937
2938 # make sure we can execute files in $TMPDIR
2939 cat > $TMPSH 2>> $logfile <<EOF
2940 #! /bin/sh
2941 EOF
2942 chmod +x $TMPSH >> $logfile 2>&1
2943 if ! $TMPSH >> $logfile 2>&1; then
2944     cat <<EOF
2945 Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
2946 variable to another directory and make sure that it is not mounted noexec.
2947 EOF
2948     die "Sanity test failed."
2949 fi
2950
2951 armasm_flags(){
2952     for flag; do
2953         case $flag in
2954             # Filter out MSVC cl.exe options from cflags that shouldn't
2955             # be passed to gas-preprocessor
2956             -M[TD]*)                                            ;;
2957             *)                  echo $flag                      ;;
2958         esac
2959    done
2960 }
2961
2962 ccc_flags(){
2963     for flag; do
2964         case $flag in
2965             -std=c99)           echo -c99                       ;;
2966             -mcpu=*)            echo -arch ${flag#*=}           ;;
2967             -mieee)             echo -ieee                      ;;
2968             -O*|-fast)          echo $flag                      ;;
2969             -fno-math-errno)    echo -assume nomath_errno       ;;
2970             -g)                 echo -g3                        ;;
2971             -Wall)              echo -msg_enable level2         ;;
2972             -Wno-pointer-sign)  echo -msg_disable ptrmismatch1  ;;
2973             -Wl,*)              echo $flag                      ;;
2974             -f*|-W*)                                            ;;
2975             *)                  echo $flag                      ;;
2976         esac
2977    done
2978 }
2979
2980 cparser_flags(){
2981     for flag; do
2982         case $flag in
2983             -Wno-switch)             echo -Wno-switch-enum ;;
2984             -Wno-format-zero-length) ;;
2985             -Wdisabled-optimization) ;;
2986             -Wno-pointer-sign)       echo -Wno-other ;;
2987             *)                       echo $flag ;;
2988         esac
2989     done
2990 }
2991
2992 msvc_common_flags(){
2993     for flag; do
2994         case $flag in
2995             # In addition to specifying certain flags under the compiler
2996             # specific filters, they must be specified here as well or else the
2997             # generic catch all at the bottom will print the original flag.
2998             -Wall)                ;;
2999             -std=c99)             ;;
3000             # Common flags
3001             -fomit-frame-pointer) ;;
3002             -g)                   echo -Z7 ;;
3003             -fno-math-errno)      ;;
3004             -fno-common)          ;;
3005             -fno-signed-zeros)    ;;
3006             -fPIC)                ;;
3007             -mthumb)              ;;
3008             -march=*)             ;;
3009             -lz)                  echo zlib.lib ;;
3010             -lavifil32)           echo vfw32.lib ;;
3011             -lavicap32)           echo vfw32.lib user32.lib ;;
3012             -lx264)               echo libx264.lib ;;
3013             -l*)                  echo ${flag#-l}.lib ;;
3014             -L*)                  echo -libpath:${flag#-L} ;;
3015             *)                    echo $flag ;;
3016         esac
3017     done
3018 }
3019
3020 msvc_flags(){
3021     msvc_common_flags "$@"
3022     for flag; do
3023         case $flag in
3024             -Wall)                echo -W4 -wd4244 -wd4127 -wd4018 -wd4389     \
3025                                        -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
3026                                        -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
3027                                        -wd4273 -wd4554 -wd4701 ;;
3028         esac
3029     done
3030 }
3031
3032 icl_flags(){
3033     msvc_common_flags "$@"
3034     for flag; do
3035         case $flag in
3036             # Despite what Intel's documentation says -Wall, which is supported
3037             # on Windows, does enable remarks so disable them here.
3038             -Wall)                echo $flag -Qdiag-disable:remark ;;
3039             -std=c99)             echo -Qstd=c99 ;;
3040         esac
3041     done
3042 }
3043
3044 pgi_flags(){
3045     for flag; do
3046         case $flag in
3047             -flto)                echo -Mipa=fast,libopt,libinline,vestigial ;;
3048             -fomit-frame-pointer) echo -Mnoframe ;;
3049             -g)                   echo -gopt ;;
3050             *)                    echo $flag ;;
3051         esac
3052     done
3053 }
3054
3055 suncc_flags(){
3056     for flag; do
3057         case $flag in
3058             -march=*|-mcpu=*)
3059                 case "${flag#*=}" in
3060                     native)                   echo -xtarget=native       ;;
3061                     v9|niagara)               echo -xarch=sparc          ;;
3062                     ultrasparc)               echo -xarch=sparcvis       ;;
3063                     ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
3064                     i586|pentium)             echo -xchip=pentium        ;;
3065                     i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
3066                     pentium3*|c3-2)           echo -xtarget=pentium3     ;;
3067                     pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
3068                     pentium4*)          echo -xtarget=pentium4           ;;
3069                     prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
3070                     *-sse3)             echo -xarch=sse3                 ;;
3071                     core2)              echo -xarch=ssse3 -xchip=core2   ;;
3072                     corei7)           echo -xarch=sse4_2 -xchip=nehalem  ;;
3073                     corei7-avx)       echo -xarch=avx -xchip=sandybridge ;;
3074                     amdfam10|barcelona|bdver*) echo -xarch=sse4_1        ;;
3075                     athlon-4|athlon-[mx]p)     echo -xarch=ssea          ;;
3076                     k8|opteron|athlon64|athlon-fx)
3077                                                echo -xarch=sse2a         ;;
3078                     athlon*)                   echo -xarch=pentium_proa  ;;
3079                 esac
3080                 ;;
3081             -std=c99)             echo -xc99              ;;
3082             -fomit-frame-pointer) echo -xregs=frameptr    ;;
3083             -fPIC)                echo -KPIC -xcode=pic32 ;;
3084             -W*,*)                echo $flag              ;;
3085             -f*-*|-W*|-mimpure-text)                      ;;
3086             -shared)              echo -G                 ;;
3087             *)                    echo $flag              ;;
3088         esac
3089     done
3090 }
3091
3092 tms470_flags(){
3093     for flag; do
3094         case $flag in
3095             -march=*|-mcpu=*)
3096                 case "${flag#*=}" in
3097                     armv7-a|cortex-a*)      echo -mv=7a8 ;;
3098                     armv7-r|cortex-r*)      echo -mv=7r4 ;;
3099                     armv7-m|cortex-m*)      echo -mv=7m3 ;;
3100                     armv6*|arm11*)          echo -mv=6   ;;
3101                     armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
3102                                             echo -mv=5e  ;;
3103                     armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
3104                 esac
3105                 ;;
3106             -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
3107             -mfpu=vfp)      echo --float_support=vfpv2        ;;
3108             -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
3109             -mfpu=vfpv3-d16) echo --float_support=vfpv3d16    ;;
3110             -msoft-float)   echo --float_support=vfplib       ;;
3111             -O[0-3]|-mf=*)  echo $flag                        ;;
3112             -g)             echo -g -mn                       ;;
3113             -pds=*)         echo $flag                        ;;
3114             -D*|-I*)        echo $flag                        ;;
3115             --gcc|--abi=*)  echo $flag                        ;;
3116             -me)            echo $flag                        ;;
3117         esac
3118     done
3119 }
3120
3121 probe_cc(){
3122     pfx=$1
3123     _cc=$2
3124
3125     unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
3126     unset _ld_o _ldflags _ld_lib _ld_path
3127     unset _depflags _DEPCMD _DEPFLAGS
3128     _flags_filter=echo
3129
3130     if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
3131         _type=llvm_gcc
3132         gcc_extra_ver=$(expr "$($_cc --version 2>/dev/null | head -n1)" : '.*\((.*)\)')
3133         _ident="llvm-gcc $($_cc -dumpversion 2>/dev/null) $gcc_extra_ver"
3134         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3135         _cflags_speed='-O3'
3136         _cflags_size='-Os'
3137     elif $_cc -v 2>&1 | grep -qi ^gcc; then
3138         _type=gcc
3139         gcc_version=$($_cc --version | head -n1)
3140         gcc_basever=$($_cc -dumpversion)
3141         gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
3142         gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
3143         _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
3144         if ! $_cc -dumpversion | grep -q '^2\.'; then
3145             _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3146         fi
3147         _cflags_speed='-O3'
3148         _cflags_size='-Os'
3149     elif $_cc --version 2>/dev/null | grep -q ^icc; then
3150         _type=icc
3151         _ident=$($_cc --version | head -n1)
3152         _depflags='-MMD'
3153         _cflags_speed='-O3'
3154         _cflags_size='-Os'
3155         _cflags_noopt='-O1'
3156     elif $_cc -v 2>&1 | grep -q xlc; then
3157         _type=xlc
3158         _ident=$($_cc -qversion 2>/dev/null | head -n1)
3159         _cflags_speed='-O5'
3160         _cflags_size='-O5 -qcompact'
3161     elif $_cc -V 2>/dev/null | grep -q Compaq; then
3162         _type=ccc
3163         _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
3164         _DEPFLAGS='-M'
3165         _cflags_speed='-fast'
3166         _cflags_size='-O1'
3167         _flags_filter=ccc_flags
3168     elif $_cc --vsn 2>/dev/null | grep -Eq "ARM (C/C\+\+ )?Compiler"; then
3169         test -d "$sysroot" || die "No valid sysroot specified."
3170         _type=armcc
3171         _ident=$($_cc --vsn | grep -i build | head -n1 | sed 's/.*: //')
3172         armcc_conf="$PWD/armcc.conf"
3173         $_cc --arm_linux_configure                 \
3174              --arm_linux_config_file="$armcc_conf" \
3175              --configure_sysroot="$sysroot"        \
3176              --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
3177              die "Error creating armcc configuration file."
3178         $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
3179         _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
3180         as_default="${cross_prefix}gcc"
3181         _depflags='-MMD'
3182         _cflags_speed='-O3'
3183         _cflags_size='-Os'
3184     elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
3185         _type=tms470
3186         _ident=$($_cc -version | head -n1 | tr -s ' ')
3187         _flags='--gcc --abi=eabi -me'
3188         _cc_e='-ppl -fe=$@'
3189         _cc_o='-fe=$@'
3190         _depflags='-ppa -ppd=$(@:.o=.d)'
3191         _cflags_speed='-O3 -mf=5'
3192         _cflags_size='-O3 -mf=2'
3193         _flags_filter=tms470_flags
3194     elif $_cc -v 2>&1 | grep -q clang; then
3195         _type=clang
3196         _ident=$($_cc --version 2>/dev/null | head -n1)
3197         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3198         _cflags_speed='-O3'
3199         _cflags_size='-Os'
3200     elif $_cc -V 2>&1 | grep -q Sun; then
3201         _type=suncc
3202         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
3203         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
3204         _DEPFLAGS='-xM1 -xc99'
3205         _ldflags='-std=c99'
3206         _cflags_speed='-O5'
3207         _cflags_size='-O5 -xspace'
3208         _flags_filter=suncc_flags
3209     elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
3210         _type=pathscale
3211         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3212         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3213         _cflags_speed='-O2'
3214         _cflags_size='-Os'
3215         _flags_filter='filter_out -Wdisabled-optimization'
3216     elif $_cc -v 2>&1 | grep -q Open64; then
3217         _type=open64
3218         _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
3219         _depflags='-MMD -MF $(@:.o=.d) -MT $@'
3220         _cflags_speed='-O2'
3221         _cflags_size='-Os'
3222         _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
3223     elif $_cc -V 2>&1 | grep -q Portland; then
3224         _type=pgi
3225         _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
3226         opt_common='-alias=ansi -Mdse -Mlre -Mpre'
3227         _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
3228         _cflags_size="-O2 -Munroll=c:1 $opt_common"
3229         _cflags_noopt="-O1"
3230         _flags_filter=pgi_flags
3231     elif $_cc 2>&1 | grep -q 'Microsoft.*ARM.*Assembler'; then
3232         _type=armasm
3233         _ident=$($_cc | head -n1)
3234         # 4509: "This form of conditional instruction is deprecated"
3235         _flags="-nologo -ignore 4509"
3236         _flags_filter=armasm_flags
3237     elif $_cc -nologo- 2>&1 | grep -q Microsoft; then
3238         _type=msvc
3239         _ident=$($_cc 2>&1 | head -n1)
3240         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
3241         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
3242         _cflags_speed="-O2"
3243         _cflags_size="-O1"
3244         if $_cc -nologo- 2>&1 | grep -q Linker; then
3245             _ld_o='-out:$@'
3246         else
3247             _ld_o='-Fe$@'
3248         fi
3249         _cc_o='-Fo$@'
3250         _cc_e='-P -Fi$@'
3251         _flags_filter=msvc_flags
3252         _ld_lib='lib%.a'
3253         _ld_path='-libpath:'
3254         _flags='-nologo'
3255     elif $_cc 2>&1 | grep -q Intel; then
3256         _type=icl
3257         _ident=$($_cc 2>&1 | head -n1)
3258         _depflags='-QMMD -QMF$(@:.o=.d) -QMT$@'
3259         # Not only is O3 broken on 13.x+ but it is slower on all previous
3260         # versions (tested) as well.
3261         _cflags_speed="-O2"
3262         _cflags_size="-O1 -Oi" # -O1 without -Oi miscompiles stuff
3263         if $_cc 2>&1 | grep -q Linker; then
3264             _ld_o='-out:$@'
3265         else
3266             _ld_o='-Fe$@'
3267         fi
3268         _cc_o='-Fo$@'
3269         _cc_e='-P'
3270         _flags_filter=icl_flags
3271         _ld_lib='lib%.a'
3272         _ld_path='-libpath:'
3273         # -Qdiag-error to make icl error when seeing certain unknown arguments
3274         _flags='-nologo -Qdiag-error:4044,10157'
3275         # -Qvec- -Qsimd- to prevent miscompilation, -GS for consistency
3276         # with MSVC which enables it by default.
3277         _cflags='-Qms0 -Qvec- -Qsimd- -GS'
3278     elif $_cc -? 2>/dev/null | grep -q 'LLVM.*Linker'; then
3279         # lld can emulate multiple different linkers; in ms link.exe mode,
3280         # the -? parameter gives the help output which contains an identifyable
3281         # string, while it gives an error in other modes.
3282         _type=lld-link
3283         # The link.exe mode doesn't have a switch for getting the version,
3284         # but we can force it back to gnu mode and get the version from there.
3285         _ident=$($_cc -flavor gnu --version)
3286         _ld_o='-out:$@'
3287         _flags_filter=msvc_flags
3288         _ld_lib='lib%.a'
3289         _ld_path='-libpath:'
3290     elif $_cc --version 2>/dev/null | grep -q ^cparser; then
3291         _type=cparser
3292         _ident=$($_cc --version | head -n1)
3293         _depflags='-MMD'
3294         _cflags_speed='-O4'
3295         _cflags_size='-O2'
3296         _flags_filter=cparser_flags
3297     fi
3298
3299     eval ${pfx}_type=\$_type
3300     eval ${pfx}_ident=\$_ident
3301 }
3302
3303 set_ccvars(){
3304     eval ${1}_C=\${_cc_c-\${${1}_C}}
3305     eval ${1}_E=\${_cc_e-\${${1}_E}}
3306     eval ${1}_O=\${_cc_o-\${${1}_O}}
3307
3308     if [ -n "$_depflags" ]; then
3309         eval ${1}_DEPFLAGS=\$_depflags
3310     else
3311         eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
3312         eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
3313         eval DEP${1}FLAGS=\$_flags
3314     fi
3315 }
3316
3317 probe_cc cc "$cc"
3318 cflags_filter=$_flags_filter
3319 cflags_speed=$_cflags_speed
3320 cflags_size=$_cflags_size
3321 cflags_noopt=$_cflags_noopt
3322 add_cflags $_flags $_cflags
3323 cc_ldflags=$_ldflags
3324 set_ccvars CC
3325
3326 probe_cc hostcc "$host_cc"
3327 host_cflags_filter=$_flags_filter
3328 add_host_cflags  $_flags $_cflags
3329 set_ccvars HOSTCC
3330
3331 test -n "$cc_type" && enable $cc_type ||
3332     warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
3333
3334 : ${as_default:=$cc}
3335 : ${objcc_default:=$cc}
3336 : ${dep_cc_default:=$cc}
3337 : ${ld_default:=$cc}
3338 : ${host_ld_default:=$host_cc}
3339 set_default ar as objcc dep_cc ld host_ld
3340
3341 probe_cc as "$as"
3342 asflags_filter=$_flags_filter
3343 add_asflags $_flags $_cflags
3344 set_ccvars AS
3345
3346 probe_cc objcc "$objcc"
3347 objcflags_filter=$_flags_filter
3348 add_objcflags $_flags $_cflags
3349 set_ccvars OBJC
3350
3351 probe_cc ld "$ld"
3352 ldflags_filter=$_flags_filter
3353 add_ldflags $_flags $_ldflags
3354 test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
3355 LD_O=${_ld_o-$LD_O}
3356 LD_LIB=${_ld_lib-$LD_LIB}
3357 LD_PATH=${_ld_path-$LD_PATH}
3358
3359 probe_cc hostld "$host_ld"
3360 host_ldflags_filter=$_flags_filter
3361 add_host_ldflags $_flags $_ldflags
3362 HOSTLD_O=${_ld_o-$HOSTLD_O}
3363
3364 if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
3365     probe_cc depcc "$dep_cc"
3366     CCDEP=${_DEPCMD:-$DEPCMD}
3367     CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
3368     DEPCCFLAGS=$_flags
3369 fi
3370
3371 if $ar 2>&1 | grep -q Microsoft; then
3372     arflags="-nologo"
3373     ar_o='-out:$@'
3374 elif $ar 2>&1 | grep -q 'Texas Instruments'; then
3375     arflags="rq"
3376     ar_o='$@'
3377 elif $ar 2>&1 | grep -q 'Usage: ar.*-X.*any'; then
3378     arflags='-Xany -r -c'
3379     ar_o='$@'
3380 else
3381     arflags="rc"
3382     ar_o='$@'
3383 fi
3384
3385 add_cflags $extra_cflags
3386 add_objcflags $extra_objcflags
3387 add_asflags $extra_cflags
3388
3389 if test -n "$sysroot"; then
3390     case "$cc_type" in
3391         gcc|llvm_gcc|clang)
3392             add_cppflags --sysroot="$sysroot"
3393             add_ldflags --sysroot="$sysroot"
3394         ;;
3395         tms470)
3396             add_cppflags -I"$sysinclude"
3397             add_ldflags  --sysroot="$sysroot"
3398         ;;
3399     esac
3400 fi
3401
3402 if test "$cpu" = host; then
3403     enabled cross_compile &&
3404         die "--cpu=host makes no sense when cross-compiling."
3405
3406     case "$cc_type" in
3407         gcc|llvm_gcc)
3408             check_native(){
3409                 $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
3410                 sed -n "/cc1.*$1=/{
3411                             s/.*$1=\\([^ ]*\\).*/\\1/
3412                             p
3413                             q
3414                         }" $TMPE
3415             }
3416             cpu=$(check_native -march || check_native -mcpu)
3417         ;;
3418     esac
3419
3420     test "${cpu:-host}" = host &&
3421         die "--cpu=host not supported with compiler $cc"
3422 fi
3423
3424 # Deal with common $arch aliases
3425 case "$arch" in
3426     aarch64|arm64)
3427         arch="aarch64"
3428     ;;
3429     arm*)
3430         arch="arm"
3431     ;;
3432     mips*|IP*)
3433         case "$arch" in
3434         *el)
3435             add_cppflags -EL
3436             add_ldflags -EL
3437         ;;
3438         *eb)
3439             add_cppflags -EB
3440             add_ldflags -EB
3441         ;;
3442         esac
3443         arch="mips"
3444     ;;
3445     parisc*|hppa*)
3446         arch="parisc"
3447     ;;
3448     "Power Macintosh"|ppc*|powerpc*)
3449         arch="ppc"
3450     ;;
3451     s390|s390x)
3452         arch="s390"
3453     ;;
3454     sh4|sh)
3455         arch="sh4"
3456     ;;
3457     sun4u|sparc*)
3458         arch="sparc"
3459     ;;
3460     tilegx|tile-gx)
3461         arch="tilegx"
3462     ;;
3463     i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
3464         arch="x86"
3465     ;;
3466 esac
3467
3468 is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
3469 enable $arch
3470
3471 # Add processor-specific flags
3472 if enabled aarch64; then
3473
3474     case $cpu in
3475         armv*)
3476             cpuflags="-march=$cpu"
3477         ;;
3478         *)
3479             cpuflags="-mcpu=$cpu"
3480         ;;
3481     esac
3482
3483 elif enabled alpha; then
3484
3485     cpuflags="-mcpu=$cpu"
3486
3487 elif enabled arm; then
3488
3489     check_arm_arch() {
3490         check_cpp_condition stddef.h \
3491             "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
3492             $cpuflags
3493     }
3494
3495     probe_arm_arch() {
3496         if   check_arm_arch 4;        then echo armv4
3497         elif check_arm_arch 4T;       then echo armv4t
3498         elif check_arm_arch 5;        then echo armv5
3499         elif check_arm_arch 5E;       then echo armv5e
3500         elif check_arm_arch 5T;       then echo armv5t
3501         elif check_arm_arch 5TE;      then echo armv5te
3502         elif check_arm_arch 5TEJ;     then echo armv5te
3503         elif check_arm_arch 6;        then echo armv6
3504         elif check_arm_arch 6J;       then echo armv6j
3505         elif check_arm_arch 6K;       then echo armv6k
3506         elif check_arm_arch 6Z;       then echo armv6z
3507         elif check_arm_arch 6ZK;      then echo armv6zk
3508         elif check_arm_arch 6T2;      then echo armv6t2
3509         elif check_arm_arch 7;        then echo armv7
3510         elif check_arm_arch 7A  7_A;  then echo armv7-a
3511         elif check_arm_arch 7S;       then echo armv7-a
3512         elif check_arm_arch 7R  7_R;  then echo armv7-r
3513         elif check_arm_arch 7M  7_M;  then echo armv7-m
3514         elif check_arm_arch 7EM 7E_M; then echo armv7-m
3515         elif check_arm_arch 8A  8_A;  then echo armv8-a
3516         fi
3517     }
3518
3519     [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
3520
3521     case $cpu in
3522         armv*)
3523             cpuflags="-march=$cpu"
3524             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
3525         ;;
3526         *)
3527             cpuflags="-mcpu=$cpu"
3528             case $cpu in
3529                 cortex-a*)                               subarch=armv7a  ;;
3530                 cortex-r*)                               subarch=armv7r  ;;
3531                 cortex-m*)                 enable thumb; subarch=armv7m  ;;
3532                 arm11*)                                  subarch=armv6   ;;
3533                 arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
3534                 armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
3535                 *)                             subarch=$(probe_arm_arch) ;;
3536             esac
3537         ;;
3538     esac
3539
3540     case "$subarch" in
3541         armv5t*)    enable fast_clz                ;;
3542         armv[6-8]*) enable fast_clz fast_unaligned ;;
3543     esac
3544
3545 elif enabled avr32; then
3546
3547     case $cpu in
3548         ap7[02]0[0-2])
3549             subarch="avr32_ap"
3550             cpuflags="-mpart=$cpu"
3551         ;;
3552         ap)
3553             subarch="avr32_ap"
3554             cpuflags="-march=$cpu"
3555         ;;
3556         uc3[ab]*)
3557             subarch="avr32_uc"
3558             cpuflags="-mcpu=$cpu"
3559         ;;
3560         uc)
3561             subarch="avr32_uc"
3562             cpuflags="-march=$cpu"
3563         ;;
3564     esac
3565
3566 elif enabled bfin; then
3567
3568     cpuflags="-mcpu=$cpu"
3569
3570 elif enabled mips; then
3571
3572     cpuflags="-march=$cpu"
3573
3574 elif enabled ppc; then
3575
3576     disable ldbrx
3577
3578     case $(tolower $cpu) in
3579         601|ppc601|powerpc601)
3580             cpuflags="-mcpu=601"
3581             disable altivec
3582         ;;
3583         603*|ppc603*|powerpc603*)
3584             cpuflags="-mcpu=603"
3585             disable altivec
3586         ;;
3587         604*|ppc604*|powerpc604*)
3588             cpuflags="-mcpu=604"
3589             disable altivec
3590         ;;
3591         g3|75*|ppc75*|powerpc75*)
3592             cpuflags="-mcpu=750"
3593             disable altivec
3594         ;;
3595         g4|745*|ppc745*|powerpc745*)
3596             cpuflags="-mcpu=7450"
3597             disable vsx
3598         ;;
3599         74*|ppc74*|powerpc74*)
3600             cpuflags="-mcpu=7400"
3601             disable vsx
3602         ;;
3603         g5|970|ppc970|powerpc970)
3604             cpuflags="-mcpu=970"
3605             disable vsx
3606         ;;
3607         power[3-6]*)
3608             cpuflags="-mcpu=$cpu"
3609             disable vsx
3610         ;;
3611         power[7-8]*)
3612             cpuflags="-mcpu=$cpu"
3613             enable ldbrx
3614         ;;
3615         cell)
3616             cpuflags="-mcpu=cell"
3617             enable ldbrx
3618             disable vsx
3619         ;;
3620         e500mc)
3621             cpuflags="-mcpu=e500mc"
3622             disable altivec
3623         ;;
3624         e500v2)
3625             cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
3626             disable altivec
3627             disable dcbzl
3628         ;;
3629         e500)
3630             cpuflags="-mcpu=8540 -mhard-float"
3631             disable altivec
3632             disable dcbzl
3633         ;;
3634     esac
3635
3636 elif enabled sparc; then
3637
3638     case $cpu in
3639         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
3640             cpuflags="-mcpu=$cpu"
3641         ;;
3642         ultrasparc*|niagara[234])
3643             cpuflags="-mcpu=$cpu"
3644         ;;
3645     esac
3646
3647 elif enabled x86; then
3648
3649     case $cpu in
3650         i[345]86|pentium)
3651             cpuflags="-march=$cpu"
3652             disable i686
3653             disable mmx
3654         ;;
3655         # targets that do NOT support nopl and conditional mov (cmov)
3656         pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
3657             cpuflags="-march=$cpu"
3658             disable i686
3659         ;;
3660         # targets that do support nopl and conditional mov (cmov)
3661         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|corei7*|amdfam10|barcelona|atom|bdver*)
3662             cpuflags="-march=$cpu"
3663             enable i686
3664             enable fast_cmov
3665         ;;
3666         # targets that do support conditional mov but on which it's slow
3667         pentium4|pentium4m|prescott|nocona)
3668             cpuflags="-march=$cpu"
3669             enable i686
3670             disable fast_cmov
3671         ;;
3672     esac
3673
3674 fi
3675
3676 if [ "$cpu" != generic ]; then
3677     add_cflags  $cpuflags
3678     add_asflags $cpuflags
3679     test "$cc_type" = "$ld_type" && add_ldflags $cpuflags
3680 fi
3681
3682 # compiler sanity check
3683 check_exec <<EOF
3684 int main(void){ return 0; }
3685 EOF
3686 if test "$?" != 0; then
3687     echo "$cc is unable to create an executable file."
3688     if test -z "$cross_prefix" && ! enabled cross_compile ; then
3689         echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
3690         echo "Only do this if you know what cross compiling means."
3691     fi
3692     die "C compiler test failed."
3693 fi
3694
3695 add_cppflags -D_ISOC99_SOURCE
3696 check_cflags -std=c99
3697 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
3698 #include <stdlib.h>
3699 EOF
3700 check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
3701 #include <stdlib.h>
3702 EOF
3703
3704 add_host_cppflags -D_ISOC99_SOURCE
3705 check_host_cflags -std=c99
3706 check_host_cflags -Wall
3707 check_host_cflags -O3
3708
3709 check_64bit(){
3710     arch32=$1
3711     arch64=$2
3712     expr=$3
3713     check_code cc "" "int test[2*($expr) - 1]" &&
3714         subarch=$arch64 || subarch=$arch32
3715 }
3716
3717 case "$arch" in
3718     aarch64|alpha|ia64)
3719         spic=$shared
3720     ;;
3721     mips)
3722         check_64bit mips mips64 '_MIPS_SIM > 1'
3723         spic=$shared
3724     ;;
3725     parisc)
3726         check_64bit parisc parisc64 'sizeof(void *) > 4'
3727         spic=$shared
3728     ;;
3729     ppc)
3730         check_64bit ppc ppc64 'sizeof(void *) > 4'
3731         spic=$shared
3732     ;;
3733     s390)
3734         check_64bit s390 s390x 'sizeof(void *) > 4'
3735         spic=$shared
3736     ;;
3737     sparc)
3738         check_64bit sparc sparc64 'sizeof(void *) > 4'
3739         spic=$shared
3740     ;;
3741     x86)
3742         check_64bit x86_32 x86_64 'sizeof(void *) > 4'
3743         if test "$subarch" = "x86_64"; then
3744             spic=$shared
3745         fi
3746     ;;
3747 esac
3748
3749 enable $subarch
3750 enabled spic && enable_weak pic
3751
3752 # OS specific
3753 case $target_os in
3754     aix)
3755         SHFLAGS=-shared
3756         add_cppflags '-I\$(SRC_PATH)/compat/aix'
3757         enabled shared && add_ldflags -Wl,-brtl
3758         ;;
3759     android)
3760         disable symver
3761         enable section_data_rel_ro
3762         SLIB_INSTALL_NAME='$(SLIBNAME)'
3763         SLIB_INSTALL_LINKS=
3764         SHFLAGS='-shared -Wl,-soname,$(SLIBNAME)'
3765         ;;
3766     haiku)
3767         prefix_default="/boot/common"
3768         network_extralibs="-lnetwork"
3769         host_libs=
3770         ;;
3771     sunos)
3772         SHFLAGS='-shared -Wl,-h,$$(@F)'
3773         enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
3774         network_extralibs="-lsocket -lnsl"
3775         # When using suncc to build, the Solaris linker will mark
3776         # an executable with each instruction set encountered by
3777         # the Solaris assembler.  As our libraries contain their own
3778         # guards for processor-specific code, instead suppress
3779         # generation of the HWCAPS ELF section on Solaris x86 only.
3780         enabled_all suncc x86 &&
3781             echo "hwcap_1 = OVERRIDE;" > mapfile &&
3782             add_ldflags -Wl,-M,mapfile
3783         nm_default='nm -P -g'
3784         version_script='-M'
3785         VERSION_SCRIPT_POSTPROCESS_CMD='perl $(SRC_PATH)/compat/solaris/make_sunver.pl - $(OBJS)'
3786         ;;
3787     netbsd)
3788         disable symver
3789         oss_indev_extralibs="-lossaudio"
3790         oss_outdev_extralibs="-lossaudio"
3791         ;;
3792     openbsd|bitrig)
3793         disable symver
3794         SHFLAGS='-shared'
3795         SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
3796         SLIB_INSTALL_LINKS=
3797         oss_indev_extralibs="-lossaudio"
3798         oss_outdev_extralibs="-lossaudio"
3799         ;;
3800     dragonfly)
3801         disable symver
3802         ;;
3803     freebsd)
3804         ;;
3805     bsd/os)
3806         add_extralibs -lpoll -lgnugetopt
3807         ;;
3808     darwin)
3809         enabled ppc && add_asflags -force_cpusubtype_ALL
3810         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
3811         enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
3812         add_ldflags -Wl,-dynamic,-search_paths_first
3813         SLIBSUF=".dylib"
3814         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
3815         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
3816         objformat="macho"
3817         enabled x86_64 && objformat="macho64"
3818         enabled_any pic shared ||
3819             { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
3820         check_header dispatch/dispatch.h &&
3821             add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
3822         ;;
3823     msys*)
3824         die "Native MSYS builds are discouraged, please use the MINGW environment."
3825         ;;
3826     mingw32*|mingw64*)
3827         if test $target_os = "mingw32ce"; then
3828             disable network
3829         else
3830             target_os=mingw32
3831         fi
3832         LIBTARGET=i386
3833         if enabled x86_64; then
3834             LIBTARGET="i386:x86-64"
3835         elif enabled arm; then
3836             LIBTARGET=arm-wince
3837         fi
3838         check_ldflags -Wl,--nxcompat
3839         check_ldflags -Wl,--dynamicbase
3840         shlibdir_default="$bindir_default"
3841         SLIBPREF=""
3842         SLIBSUF=".dll"
3843         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3844         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3845         SLIB_EXTRA_CMD=-'sed -e "s/ @[^ ]*//" $$(@:$(SLIBSUF)=.orig.def) > $$(@:$(SLIBSUF)=.def); $(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
3846         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3847         SLIB_INSTALL_LINKS=
3848         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3849         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3850         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.orig.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
3851         objformat="win32"
3852         dlltool="${cross_prefix}dlltool"
3853         ranlib=:
3854         enable dos_paths
3855         ;;
3856     win32|win64)
3857         disable symver
3858         if enabled shared; then
3859             # Link to the import library instead of the normal static library
3860             # for shared libs.
3861             LD_LIB='%.lib'
3862             # Cannot build both shared and static libs with MSVC or icl.
3863             disable static
3864         fi
3865         shlibdir_default="$bindir_default"
3866         SLIBPREF=""
3867         SLIBSUF=".dll"
3868         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3869         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3870         SLIB_CREATE_DEF_CMD='$(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
3871         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3872         SLIB_INSTALL_LINKS=
3873         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
3874         SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
3875         SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
3876         objformat="win32"
3877         ranlib=:
3878         enable dos_paths
3879         ;;
3880     cygwin*)
3881         target_os=cygwin
3882         shlibdir_default="$bindir_default"
3883         SLIBPREF="cyg"
3884         SLIBSUF=".dll"
3885         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
3886         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
3887         SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
3888         SLIB_INSTALL_LINKS=
3889         SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
3890         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
3891         objformat="win32"
3892         enable dos_paths
3893         ;;
3894     *-dos|freedos|opendos)
3895         network_extralibs="-lsocket"
3896         objformat="coff"
3897         enable dos_paths
3898         add_cppflags -U__STRICT_ANSI__
3899         ;;
3900     linux)
3901         enable dv1394
3902         enable section_data_rel_ro
3903         ;;
3904     irix*)
3905         target_os=irix
3906         ranlib="echo ignoring ranlib"
3907         ;;
3908     os/2*)
3909         ln_s="cp -f"
3910         objformat="aout"
3911         add_cppflags -D_GNU_SOURCE
3912         add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
3913         SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
3914         LIBSUF="_s.a"
3915         SLIBPREF=""
3916         SLIBSUF=".dll"
3917         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
3918         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
3919         SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
3920             echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
3921             echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
3922             echo EXPORTS >> $(SUBDIR)$(NAME).def; \
3923             emxexp $(OBJS) >> $(SUBDIR)$(NAME).def'
3924         SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
3925             emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
3926         SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
3927         enable dos_paths
3928         ;;
3929     gnu/kfreebsd)
3930         add_cppflags -D_BSD_SOURCE
3931         ;;
3932     gnu)
3933         ;;
3934     qnx)
3935         add_cppflags -D_QNX_SOURCE
3936         network_extralibs="-lsocket"
3937         ;;
3938     symbian)
3939         SLIBSUF=".dll"
3940         enable dos_paths
3941         add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
3942         add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
3943         add_ldflags -Wl,--target1-abs,--no-undefined \
3944                     -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
3945                     -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
3946         add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
3947                       -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
3948                       -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
3949         ;;
3950     osf1)
3951         add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
3952         ;;
3953     minix)
3954         ;;
3955     plan9)
3956         add_cppflags -D_C99_SNPRINTF_EXTENSION  \
3957                      -D_REENTRANT_SOURCE        \
3958                      -D_RESEARCH_SOURCE         \
3959                      -DFD_SETSIZE=96            \
3960                      -DHAVE_SOCK_OPTS
3961         add_compat strtod.o strtod=avpriv_strtod
3962         network_extralibs='-lbsd'
3963         exeobjs=compat/plan9/main.o
3964         cp_f='cp'
3965         ;;
3966     none)
3967         ;;
3968     *)
3969         die "Unknown OS '$target_os'."
3970         ;;
3971 esac
3972
3973 # determine libc flavour
3974
3975 probe_libc(){
3976     pfx=$1
3977     pfx_no_=${pfx%_}
3978     # uclibc defines __GLIBC__, so it needs to be checked before glibc.
3979     if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
3980         eval ${pfx}libc_type=uclibc
3981         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3982     elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
3983         eval ${pfx}libc_type=glibc
3984         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
3985     # MinGW headers can be installed on Cygwin, so check for newlib first.
3986     elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
3987         eval ${pfx}libc_type=newlib
3988         add_${pfx}cppflags -U__STRICT_ANSI__
3989     # MinGW64 is backwards compatible with MinGW32, so check for it first.
3990     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR"; then
3991         eval ${pfx}libc_type=mingw64
3992         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
3993         eval test \$${pfx_no_}cc_type = "gcc" &&
3994             add_${pfx}cppflags -D__printf__=__gnu_printf__
3995     elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION"  ||
3996          check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
3997         eval ${pfx}libc_type=mingw32
3998         check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
3999             (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
4000             die "ERROR: MinGW32 runtime version must be >= 3.15."
4001         add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
4002         eval test \$${pfx_no_}cc_type = "gcc" &&
4003             add_${pfx}cppflags -D__printf__=__gnu_printf__
4004     elif check_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
4005         eval ${pfx}libc_type=msvcrt
4006         if check_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14"; then
4007             if [ "$pfx" = host_ ]; then
4008                 add_host_cppflags -Dsnprintf=_snprintf
4009             else
4010                 add_compat strtod.o strtod=avpriv_strtod
4011                 add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf   \
4012                                              _snprintf=avpriv_snprintf  \
4013                                              vsnprintf=avpriv_vsnprintf
4014             fi
4015         fi
4016         add_${pfx}cppflags -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS
4017         # The MSVC 2010 headers (Win 7.0 SDK) set _WIN32_WINNT to
4018         # 0x601 by default unless something else is set by the user.
4019         # This can easily lead to us detecting functions only present
4020         # in such new versions and producing binaries requiring windows 7.0.
4021         # Therefore explicitly set the default to XP unless the user has
4022         # set something else on the command line.
4023         # Don't do this if WINAPI_FAMILY is set and is set to a non-desktop
4024         # family. For these cases, configure is free to use any functions
4025         # found in the SDK headers by default. (Alternatively, we could force
4026         # _WIN32_WINNT to 0x0602 in that case.)
4027         check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
4028             { check_${pfx}cpp <<EOF && add_${pfx}cppflags -D_WIN32_WINNT=0x0502; }
4029 #ifdef WINAPI_FAMILY
4030 #include <winapifamily.h>
4031 #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
4032 #error not desktop
4033 #endif
4034 #endif
4035 EOF
4036         if [ "$pfx" = "" ]; then
4037             check_func strtoll || add_cflags -Dstrtoll=_strtoi64
4038         fi
4039     elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
4040         eval ${pfx}libc_type=klibc
4041     elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
4042         eval ${pfx}libc_type=bionic
4043     elif check_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME"; then
4044         eval ${pfx}libc_type=solaris
4045         add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
4046     else
4047         eval ${pfx}libc_type=default
4048         add_${pfx}cppflags -D_DEFAULT_SOURCE
4049     fi
4050 }
4051
4052 probe_libc
4053 test -n "$libc_type" && enable libc_$libc_type
4054 probe_libc host_
4055 test -n "$host_libc_type" && enable host_libc_$host_libc_type
4056
4057 case $libc_type in
4058     bionic)
4059         add_compat strtod.o strtod=avpriv_strtod
4060         ;;
4061 esac
4062
4063 # hacks for compiler/libc/os combinations
4064
4065 if enabled_all tms470 libc_glibc; then
4066     CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
4067     add_cppflags -D__USER_LABEL_PREFIX__=
4068     add_cppflags -D__builtin_memset=memset
4069     add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
4070     add_cflags   -pds=48    # incompatible redefinition of macro
4071 fi
4072
4073 if enabled_all ccc libc_glibc; then
4074     add_ldflags -Wl,-z,now  # calls to libots crash without this
4075 fi
4076
4077 check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" ||
4078     add_cppflags '-I\$(SRC_PATH)/compat/float'
4079
4080 esc(){
4081     echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
4082 }
4083
4084 echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" >config.fate
4085
4086 check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable_weak pic
4087
4088 set_default $PATHS_LIST
4089 set_default nm
4090
4091 # we need to build at least one lib type
4092 if ! enabled_any static shared; then
4093     cat <<EOF
4094 At least one library type must be built.
4095 Specify --enable-static to build the static libraries or --enable-shared to
4096 build the shared libraries as well. To only build the shared libraries specify
4097 --disable-static in addition to --enable-shared.
4098 EOF
4099     exit 1
4100 fi
4101
4102 die_license_disabled() {
4103     enabled $1 || { enabled $v && die "$v is $1 and --enable-$1 is not specified."; }
4104 }
4105
4106 map "die_license_disabled gpl"      $EXTERNAL_LIBRARY_GPL_LIST
4107 map "die_license_disabled nonfree"  $EXTERNAL_LIBRARY_NONFREE_LIST $HWACCEL_LIBRARY_NONFREE_LIST
4108 map "die_license_disabled version3" $EXTERNAL_LIBRARY_VERSION3_LIST
4109
4110 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
4111
4112 disabled optimizations || check_cflags -fomit-frame-pointer
4113
4114 enable_weak_pic() {
4115     disabled pic && return
4116     enable pic
4117     add_cppflags -DPIC
4118     case "$target_os" in
4119     mingw*|cygwin*)
4120         ;;
4121     *)
4122         add_cflags -fPIC
4123         ;;
4124     esac
4125     add_asflags  -fPIC
4126 }
4127
4128 enabled pic && enable_weak_pic
4129
4130 check_cc <<EOF || die "Symbol mangling check failed."
4131 int ff_extern;
4132 EOF
4133 sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
4134 extern_prefix=${sym%%ff_extern*}
4135
4136 check_cc <<EOF && enable_weak inline_asm
4137 void foo(void) { __asm__ volatile ("" ::); }
4138 EOF
4139
4140 _restrict=
4141 for restrict_keyword in restrict __restrict__ __restrict; do
4142     check_cc <<EOF && _restrict=$restrict_keyword && break
4143 void foo(char * $restrict_keyword p);
4144 EOF
4145 done
4146
4147 check_cc <<EOF && enable pragma_deprecated
4148 void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
4149 EOF
4150
4151 check_cc <<EOF && enable attribute_packed
4152 struct { int x; } __attribute__((packed)) x;
4153 EOF
4154
4155 check_cc <<EOF && enable attribute_may_alias
4156 union { int x; } __attribute__((may_alias)) x;
4157 EOF
4158
4159 check_cc <<EOF || die "endian test failed"
4160 unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
4161 EOF
4162 od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
4163
4164 check_gas() {
4165     log "check_gas using '$as' as AS"
4166     # :vararg is used on aarch64, arm and ppc altivec
4167     check_as <<EOF || return 1
4168 .macro m n, y:vararg=0
4169 \n: .int \y
4170 .endm
4171 m x
4172 EOF
4173     # .altmacro is only used in arm asm
4174     ! enabled arm || check_as <<EOF || return 1
4175 .altmacro
4176 EOF
4177     enable gnu_as
4178     return 0
4179 }
4180
4181 if enabled_any arm aarch64 || enabled_all ppc altivec && enabled asm; then
4182     nogas=:
4183     enabled_any arm aarch64 && nogas=die
4184     enabled_all ppc altivec && nogas=warn
4185     as_noop=-v
4186
4187     case $as_type in
4188         arm*) gaspp_as_type=armasm; as_noop=-h ;;
4189         gcc)  gaspp_as_type=gas ;;
4190         *)    gaspp_as_type=$as_type ;;
4191     esac
4192
4193     [ $target_os = "darwin" ] && gaspp_as_type="apple-$gaspp_as_type"
4194
4195     check_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- $as $as_noop &&
4196         gas="gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- $as"
4197
4198     if ! check_gas ; then
4199         as=${gas:=$as}
4200         check_gas || \
4201             $nogas "GNU assembler not found, install/update gas-preprocessor"
4202     fi
4203
4204     check_as <<EOF && enable as_func
4205 .func test
4206 .endfunc
4207 EOF
4208 fi
4209
4210 check_inline_asm inline_asm_labels '"1:\n"'
4211
4212 if enabled aarch64; then
4213     enabled armv8 && check_insn armv8 'prfm   pldl1strm, [x0]'
4214     # internal assembler in clang 3.3 does not support this instruction
4215     enabled neon && check_insn neon 'ext   v0.8B, v0.8B, v1.8B, #1'
4216     enabled vfp  && check_insn vfp  'fmadd d0,    d0,    d1,    d2'
4217
4218     map 'enabled_any ${v}_external ${v}_inline || disable $v' $ARCH_EXT_LIST_ARM
4219
4220 elif enabled alpha; then
4221
4222     check_cflags -mieee
4223
4224 elif enabled arm; then
4225
4226     enabled msvc && check_cpp_condition stddef.h "defined _M_ARMT" && enable thumb
4227     check_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
4228     enabled thumb && check_cflags -mthumb || check_cflags -marm
4229
4230     if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
4231         enable vfp_args
4232     elif check_cpp_condition stddef.h "defined _M_ARM_FP && _M_ARM_FP >= 30"; then
4233         enable vfp_args
4234     elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__" && [ $target_os != darwin ]; then
4235         case "${cross_prefix:-$cc}" in
4236             *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
4237             *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
4238 __asm__ (".eabi_attribute 28, 1");
4239 int main(void) { return 0; }
4240 EOF
4241         esac
4242         warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
4243     fi
4244
4245     enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
4246     enabled armv6   && check_insn armv6   'sadd16 r0, r0, r0'
4247     enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
4248     enabled neon    && check_insn neon    'vadd.i16 q0, q0, q0'
4249     enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
4250     enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
4251
4252     [ $target_os = linux ] || [ $target_os = android ] ||
4253         map 'enabled_any ${v}_external ${v}_inline || disable $v' \
4254             $ARCH_EXT_LIST_ARM
4255
4256     check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
4257
4258     check_as <<EOF && enable as_dn_directive
4259 ra .dn d0.i16
4260 .unreq ra
4261 EOF
4262     check_as <<EOF && enable as_fpu_directive
4263 .fpu neon
4264 EOF
4265
4266     # llvm's integrated assembler supports .object_arch from llvm 3.5
4267     [ "$objformat" = elf ] && check_as <<EOF && enable as_object_arch
4268 .object_arch armv4
4269 EOF
4270
4271     [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
4272
4273 elif enabled mips; then
4274
4275     check_inline_asm loongson '"dmult.g $1, $2, $3"'
4276
4277     # make sure that only an instruction set is enabled
4278     disable mips64r6 mips32r6 mips64r2 mips32r2 mips64r1 mips32r1
4279
4280     if enabled mips64; then
4281         check_inline_asm mips64r6 '"dlsa $0, $0, $0, 1"' ||
4282             check_inline_asm mips64r2 '"dext $0, $0, 0, 1"' ||
4283                 check_inline_asm mips64r1 '"daddi $0, $0, 0"'
4284     else
4285         check_inline_asm mips32r6 '"aui $0, $0, 0"' ||
4286             check_inline_asm mips32r2 '"ext $0, $0, 0, 1"' ||
4287                 check_inline_asm mips32r1 '"addi $0, $0, 0"'
4288     fi
4289
4290 elif enabled parisc; then
4291
4292     if enabled gcc; then
4293         case $($cc -dumpversion) in
4294             4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
4295         esac
4296     fi
4297
4298 elif enabled ppc; then
4299
4300     enable local_aligned_8 local_aligned_16 local_aligned_32
4301
4302     check_inline_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
4303     check_inline_asm ibm_asm   '"add 0, 0, 0"'
4304     check_inline_asm ppc4xx    '"maclhw r10, r11, r12"'
4305     check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
4306
4307     # AltiVec flags: The FSF version of GCC differs from the Apple version
4308     if enabled altivec; then
4309         check_cflags -maltivec -mabi=altivec &&
4310         { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
4311         check_cflags -faltivec
4312
4313         # check if our compiler supports Motorola AltiVec C API
4314         check_cc <<EOF || disable altivec
4315 $inc_altivec_h
4316 int main(void) {
4317     vector signed int v1 = (vector signed int) { 0 };
4318     vector signed int v2 = (vector signed int) { 1 };
4319     v1 = vec_add(v1, v2);
4320     return 0;
4321 }
4322 EOF
4323
4324         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
4325     fi
4326
4327     if enabled vsx; then
4328         check_cflags -mvsx &&
4329         check_builtin vec_vsx_ld "altivec.h" "__builtin_vec_vsx_ld" || disable vsx
4330     fi
4331
4332     if enabled power8; then
4333         check_cpp_condition "altivec.h" "defined(_ARCH_PWR8)" || disable power8
4334     fi
4335
4336 elif enabled x86; then
4337
4338     check_builtin rdtsc    intrin.h   "__rdtsc()"
4339     check_builtin mm_empty mmintrin.h "_mm_empty()"
4340
4341     enable local_aligned_8 local_aligned_16 local_aligned_32
4342
4343     # check whether EBP is available on x86
4344     # As 'i' is stored on the stack, this program will crash
4345     # if the base pointer is used to access it because the
4346     # base pointer is cleared in the inline assembly code.
4347     check_exec_crash <<EOF && enable ebp_available
4348 volatile int i=0;
4349 __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
4350 return i;
4351 EOF
4352
4353     # check whether EBX is available on x86
4354     check_inline_asm ebx_available '""::"b"(0)' &&
4355         check_inline_asm ebx_available '"":::"%ebx"'
4356
4357     # check whether xmm clobbers are supported
4358     check_inline_asm xmm_clobbers '"":::"%xmm0"'
4359
4360     # check whether binutils is new enough to compile SSSE3/MMXEXT
4361     enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0, %xmm0"'
4362     enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
4363
4364     if ! disabled_any asm mmx yasm; then
4365         if check_cmd $yasmexe --version; then
4366             enabled x86_64 && yasm_extra="-m amd64"
4367             yasm_debug="-g dwarf2"
4368         elif check_cmd nasm -v; then
4369             yasmexe=nasm
4370             yasm_debug="-g -F dwarf"
4371             enabled x86_64 && test "$objformat" = elf && objformat=elf64
4372         fi
4373
4374         YASMFLAGS="-f $objformat $yasm_extra"
4375         enabled pic               && append YASMFLAGS "-DPIC"
4376         test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
4377         case "$objformat" in
4378             elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
4379         esac
4380
4381         check_yasm "movbe ecx, [5]" && enable yasm ||
4382             die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
4383         check_yasm "vextracti128 xmm0, ymm0, 0"      || disable avx2_external
4384         check_yasm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
4385         check_yasm "vfmadd132ps ymm0, ymm1, ymm2"    || disable fma3_external
4386         check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
4387         check_yasm "CPU amdnop" || disable cpunop
4388     fi
4389
4390     case "$cpu" in
4391         athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
4392             disable fast_clz
4393         ;;
4394     esac
4395
4396 fi
4397
4398 check_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_neon
4399
4400 check_ldflags -Wl,--as-needed
4401
4402 if check_func dlopen; then
4403     ldl=
4404 elif check_func dlopen -ldl; then
4405     ldl=-ldl
4406 fi
4407
4408 if ! disabled network; then
4409     check_func getaddrinfo $network_extralibs
4410     check_func inet_aton $network_extralibs
4411
4412     check_type netdb.h "struct addrinfo"
4413     check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
4414     check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
4415     check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
4416     check_type poll.h "struct pollfd"
4417     check_type netinet/sctp.h "struct sctp_event_subscribe"
4418     check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
4419     check_type netinet/in.h "struct sockaddr_in6"
4420     check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
4421     check_type "sys/types.h sys/socket.h" socklen_t
4422
4423     # Prefer arpa/inet.h over winsock2
4424     if check_header arpa/inet.h ; then
4425         check_func closesocket
4426     elif check_header winsock2.h ; then
4427         check_func_headers winsock2.h closesocket -lws2 &&
4428             network_extralibs="-lws2" ||
4429         { check_func_headers winsock2.h closesocket -lws2_32 &&
4430             network_extralibs="-lws2_32"; } || disable winsock2_h network
4431         check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
4432
4433         check_type ws2tcpip.h socklen_t
4434         check_type ws2tcpip.h "struct addrinfo"
4435         check_type ws2tcpip.h "struct group_source_req"
4436         check_type ws2tcpip.h "struct ip_mreq_source"
4437         check_type ws2tcpip.h "struct ipv6_mreq"
4438         check_type winsock2.h "struct pollfd"
4439         check_struct winsock2.h "struct sockaddr" sa_len
4440         check_type ws2tcpip.h "struct sockaddr_in6"
4441         check_type ws2tcpip.h "struct sockaddr_storage"
4442     else
4443         disable network
4444     fi
4445 fi
4446
4447 check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; atomic_cas_ptr(ptr, oldval, newval)"
4448 check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
4449 check_builtin MemoryBarrier windows.h "MemoryBarrier()"
4450 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
4451
4452 case "$custom_allocator" in
4453     jemalloc)
4454         # jemalloc by default does not use a prefix
4455         require libjemalloc jemalloc/jemalloc.h malloc -ljemalloc
4456     ;;
4457     tcmalloc)
4458         require_pkg_config libtcmalloc gperftools/tcmalloc.h tc_malloc
4459         malloc_prefix=tc_
4460     ;;
4461 esac
4462
4463 check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
4464 check_func  ${malloc_prefix}memalign            && enable memalign
4465 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
4466
4467 check_cpp_condition unistd.h "defined(_POSIX_MONOTONIC_CLOCK)" &&
4468     check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
4469
4470 check_func  fcntl
4471 check_func  fork
4472 check_func  gethrtime
4473 check_func  getopt
4474 check_func  getrusage
4475 check_func  gettimeofday
4476 check_func  gmtime_r
4477 check_func  isatty
4478 check_func  localtime_r
4479 check_func  mach_absolute_time
4480 check_func  mkstemp
4481 check_func  mmap
4482 check_func  mprotect
4483 # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
4484 check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep -lrt && add_extralibs -lrt; }
4485 check_func  sched_getaffinity
4486 check_func  setrlimit
4487 check_func  strerror_r
4488 check_func  sysconf
4489 check_func  sysctl
4490 check_func  usleep
4491
4492 check_func_headers io.h setmode
4493 check_func_headers stdlib.h getenv
4494
4495 check_func_headers windows.h CoTaskMemFree -lole32
4496 check_func_headers windows.h GetProcessAffinityMask
4497 check_func_headers windows.h GetProcessTimes
4498 check_func_headers windows.h GetSystemTimeAsFileTime
4499 check_func_headers windows.h LoadLibrary
4500 check_func_headers windows.h MapViewOfFile
4501 check_func_headers windows.h SetConsoleTextAttribute
4502 check_func_headers windows.h Sleep
4503 check_func_headers windows.h VirtualAlloc
4504 check_struct windows.h "CONDITION_VARIABLE" Ptr
4505
4506 check_header direct.h
4507 check_header dlfcn.h
4508 check_header d3d11.h
4509 check_header dxva.h
4510 check_header dxva2api.h
4511 check_header io.h
4512 check_header mach/mach_time.h
4513 check_header malloc.h
4514 check_header poll.h
4515 check_header sys/mman.h
4516 check_header sys/param.h
4517 check_header sys/resource.h
4518 check_header sys/select.h
4519 check_header sys/time.h
4520 check_header sys/un.h
4521 check_header unistd.h
4522 check_header valgrind/valgrind.h
4523 check_header vdpau/vdpau.h
4524 check_header vdpau/vdpau_x11.h
4525 check_header VideoDecodeAcceleration/VDADecoder.h
4526 check_header windows.h
4527 check_header X11/extensions/XvMClib.h
4528
4529 check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
4530 check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
4531 check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
4532
4533 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
4534
4535 check_type "windows.h dxva.h" "DXVA_PicParams_HEVC" -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -D_CRT_BUILD_DESKTOP_APP=0
4536 check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
4537 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
4538
4539 check_type "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
4540 check_type "va/va.h va/va_enc_h264.h" "VAEncPictureParameterBufferH264"
4541 check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
4542 check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
4543
4544 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
4545
4546 if ! disabled w32threads && ! enabled pthreads; then
4547     check_func_headers "windows.h process.h" _beginthreadex &&
4548         enable w32threads || disable w32threads
4549 fi
4550
4551 # check for some common methods of building with pthread support
4552 # do this before the optional library checks as some of them require pthreads
4553 if ! disabled pthreads && ! enabled w32threads; then
4554     enable pthreads
4555     if check_func pthread_join -pthread; then
4556         add_cflags -pthread
4557         add_extralibs -pthread
4558     elif check_func pthread_join -pthreads; then
4559         add_cflags -pthreads
4560         add_extralibs -pthreads
4561     elif check_func pthread_join -lpthreadGC2; then
4562         add_extralibs -lpthreadGC2
4563     elif check_lib pthread.h pthread_join -lpthread; then
4564         :
4565     elif ! check_func pthread_join; then
4566         disable pthreads
4567     fi
4568 fi
4569
4570 enabled pthreads &&
4571     check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)"
4572
4573 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
4574 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
4575
4576 check_lib math.h sin -lm && LIBM="-lm"
4577 enabled vaapi && require vaapi va/va.h vaInitialize -lva
4578
4579 atan2f_args=2
4580 ldexpf_args=2
4581 powf_args=2
4582
4583 for func in $MATH_FUNCS; do
4584     eval check_mathfunc $func \${${func}_args:-1}
4585 done
4586
4587 # these are off by default, so fail if requested and not available
4588 enabled avisynth          && { check_lib2 "avisynth/avisynth_c.h windows.h" LoadLibrary ||
4589                                check_lib2 "avxsynth/avxsynth_c.h dlfcn.h" dlopen -ldl   ||
4590                                die "ERROR: LoadLibrary/dlopen not found, or avisynth header not found"; }
4591 enabled cuda              && check_lib cuda.h cuInit -lcuda
4592 enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
4593 enabled gnutls            && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
4594 enabled libbs2b           && require_pkg_config libbs2b bs2b.h bs2b_open
4595 enabled libdcadec         && require libdcadec libdcadec/dca_context.h dcadec_context_create -ldcadec
4596 enabled libfaac           && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
4597 enabled libfdk_aac        && require_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen
4598 enabled libfontconfig     && require_pkg_config fontconfig "fontconfig/fontconfig.h" FcInit
4599 enabled libfreetype       && require_pkg_config freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType
4600 enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
4601                                    check_lib "${gsm_hdr}" gsm_create -lgsm && break;
4602                                done || die "ERROR: libgsm not found"; }
4603 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
4604 enabled libkvazaar        && require_pkg_config "kvazaar >= 0.8.1" kvazaar.h kvz_api_get
4605 enabled libmfx            && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit
4606 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
4607 enabled libnpp            && require libnpp npp.h nppGetLibVersion -lnppi -lnppc
4608 enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
4609 enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
4610 enabled libopencv         && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
4611 enabled libopenh264       && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion
4612 enabled libopenjpeg       && { { check_header openjpeg.h && check_lib2 openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC; } ||
4613                                { require_pkg_config libopenjpeg1 openjpeg.h opj_version -DOPJ_STATIC; } }
4614 enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
4615 enabled libpulse          && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
4616 enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
4617 enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
4618 enabled libsnappy         && require snappy snappy-c.h snappy_compress -lsnappy
4619 enabled libspeex          && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex
4620 enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
4621 enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame
4622 enabled libvo_aacenc      && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
4623 enabled libvo_amrwbenc    && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
4624 enabled libvorbis         && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
4625 enabled libvpx            && require_pkg_config "vpx >= 1.3.0" vpx/vpx_codec.h vpx_codec_version && {
4626     enabled libvpx_vp8_decoder && {
4627         check_pkg_config vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp8_dx ||
4628             disable libvpx_vp8_decoder;
4629     }
4630     enabled libvpx_vp8_encoder && {
4631         check_pkg_config vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp8_cx ||
4632             disable libvpx_vp8_encoder;
4633     }
4634     enabled libvpx_vp9_decoder && {
4635         check_pkg_config vpx "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_vp9_dx ||
4636             disable libvpx_vp9_decoder;
4637     }
4638     enabled libvpx_vp9_encoder && {
4639         check_pkg_config vpx "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_vp9_cx ||
4640             disable libvpx_vp9_encoder;
4641     }
4642     if disabled_all libvpx_vp8_decoder libvpx_vp9_decoder libvpx_vp8_encoder libvpx_vp9_encoder; then
4643         die "libvpx enabled but no supported decoders found"
4644     fi
4645 }
4646 enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
4647 enabled libwebp           && require_pkg_config libwebp webp/encode.h WebPGetEncoderVersion
4648 enabled libx264           && require_pkg_config x264 "stdint.h x264.h" x264_encoder_encode &&
4649                              { check_cpp_condition x264.h "X264_BUILD >= 118" ||
4650                                die "ERROR: libx264 version must be >= 0.118."; } &&
4651                              { check_cpp_condition x264.h "X264_MPEG2" &&
4652                                enable libx262; }
4653 enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
4654                              { check_cpp_condition x265.h "X265_BUILD >= 57" ||
4655                                die "ERROR: libx265 version must be >= 57."; }
4656 enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
4657 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
4658 enabled mmal              && { check_lib interface/mmal/mmal.h mmal_port_connect -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ||
4659                                 { ! enabled cross_compile && {
4660                                     add_cflags -isystem/opt/vc/include/ -isystem/opt/vc/include/interface/vmcs_host/linux -isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline ;
4661                                     add_extralibs -L/opt/vc/lib/ -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host ;
4662                                     check_lib interface/mmal/mmal.h mmal_port_connect ; }
4663                                 check_lib interface/mmal/mmal.h mmal_port_connect ; } ||
4664                                die "ERROR: mmal not found"; }
4665 enabled mmal && check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"
4666 enabled omx_rpi && enable omx
4667 enabled omx               && { check_header OMX_Core.h ||
4668                                 { ! enabled cross_compile && enabled omx_rpi && {
4669                                     add_cflags -isystem/opt/vc/include/IL ; }
4670                                 check_header OMX_Core.h ; } ||
4671                                die "ERROR: OpenMAX IL headers not found"; }
4672 enabled openssl           && { check_pkg_config openssl openssl/ssl.h SSL_library_init && {
4673                                add_cflags $openssl_cflags && add_extralibs $openssl_libs; }||
4674                                check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
4675                                check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
4676                                check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
4677                                die "ERROR: openssl not found"; }
4678
4679 if enabled gnutls; then
4680     { check_lib2 gmp.h mpz_export -lgmp && enable gmp; } ||
4681     { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
4682 fi
4683
4684 # libdc1394 check
4685 if enabled libdc1394; then
4686     { require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new &&
4687         enable libdc1394_2; } ||
4688     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
4689         enable libdc1394_1; } ||
4690     die "ERROR: No version of libdc1394 found "
4691 fi
4692
4693 if enabled nvenc; then
4694     check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."
4695     check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 6" ||
4696         die "ERROR: NVENC API version 5 or older is not supported"
4697 fi
4698
4699 if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
4700     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
4701     check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
4702     enable sdl
4703 fi
4704
4705 pod2man --help     > /dev/null 2>&1 && enable pod2man   || disable pod2man
4706 texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
4707
4708 check_header linux/fb.h
4709 check_header linux/videodev2.h
4710 check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
4711
4712 check_header AVFoundation/AVFoundation.h &&
4713     check_objcflags -fobjc-arc &&
4714     add_extralibs -framework Foundation -framework AVFoundation -framework CoreVideo -framework CoreMedia ||
4715     disable AVFoundation_AVFoundation_h
4716
4717 check_header sys/videoio.h
4718
4719 check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
4720 # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
4721 # w32api 3.12 had it defined wrong
4722 check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
4723
4724 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
4725 { check_header dev/bktr/ioctl_meteor.h &&
4726   check_header dev/bktr/ioctl_bt848.h; } ||
4727 { check_header machine/ioctl_meteor.h &&
4728   check_header machine/ioctl_bt848.h; } ||
4729 { check_header dev/video/meteor/ioctl_meteor.h &&
4730   check_header dev/video/bktr/ioctl_bt848.h; } ||
4731 check_header dev/ic/bt8xx.h
4732
4733 check_header sndio.h
4734 check_header sys/soundcard.h
4735 check_header soundcard.h
4736
4737 enabled_any alsa_indev alsa_outdev &&
4738     check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
4739
4740 enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack &&
4741     check_func jack_port_get_latency_range -ljack
4742
4743 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
4744
4745 if enabled libcdio; then
4746     check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
4747     check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
4748     die "ERROR: No usable libcdio/cdparanoia found"
4749 fi
4750
4751 check_lib X11/Xlib.h XOpenDisplay -lX11 && enable xlib
4752
4753 if enabled libxcb; then
4754     check_pkg_config xcb-shape xcb/shape.h xcb_shape_rectangles || {
4755         enabled libxcb && die "ERROR: libxcb not found";
4756     } && enable libxcb
4757
4758     disabled libxcb_shm ||
4759         check_pkg_config xcb-shm xcb/shm.h xcb_shm_attach || {
4760             enabled libxcb_shm && die "ERROR: libxcb_shm not found";
4761         } && check_header sys/shm.h && enable libxcb_shm
4762
4763     disabled libxcb_xfixes ||
4764         check_pkg_config xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image || {
4765             enabled libxcb_xfixes && die "ERROR: libxcb_xfixes not found";
4766         } && enable libxcb_xfixes
4767
4768     add_cflags "$xcb_event_cflags $xcb_shm_cflags $xcb_xfixes_cflags"
4769     add_extralibs "$xcb_event_libs $xcb_shm_libs $xcb_xfixes_libs"
4770 fi
4771
4772 enabled vaapi &&
4773     check_code cc "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)" ||
4774     disable vaapi
4775
4776 if enabled vaapi ; then
4777     enabled xlib &&
4778     check_lib2 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 &&
4779     enable vaapi_x11
4780
4781     check_lib2 "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm &&
4782     enable vaapi_drm
4783 fi
4784
4785 enabled vdpau &&
4786     check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
4787     disable vdpau
4788
4789 enabled vdpau && enabled xlib &&
4790     check_lib2 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
4791     enable vdpau_x11
4792
4793 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
4794
4795 # add some useful compiler flags if supported
4796 check_cflags -Wdeclaration-after-statement
4797 check_cflags -Wall
4798 check_cflags -Wdisabled-optimization
4799 check_cflags -Wpointer-arith
4800 check_cflags -Wredundant-decls
4801 check_cflags -Wwrite-strings
4802 check_cflags -Wtype-limits
4803 check_cflags -Wundef
4804 check_cflags -Wmissing-prototypes
4805 check_cflags -Wstrict-prototypes
4806 enabled extra_warnings && check_cflags -Winline
4807 enabled extra_warnings && check_cflags -Wcast-qual
4808
4809 check_disable_warning(){
4810     warning_flag=-W${1#-Wno-}
4811     test_cflags $warning_flag && add_cflags $1
4812 }
4813
4814 check_disable_warning -Wno-parentheses
4815 check_disable_warning -Wno-switch
4816 check_disable_warning -Wno-format-zero-length
4817 check_disable_warning -Wno-pointer-sign
4818
4819 # add some linker flags
4820 check_ldflags -Wl,--warn-common
4821 check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
4822 enabled rpath && add_ldexeflags -Wl,-rpath,$libdir
4823 test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
4824
4825 # add some strip flags
4826 # -wN '..@*' is more selective than -x, but not available everywhere.
4827 check_stripflags -wN \'..@*\' || check_stripflags -x || strip='true'
4828
4829 enabled neon_clobber_test &&
4830     check_ldflags -Wl,--wrap,avcodec_open2              \
4831                   -Wl,--wrap,avcodec_decode_audio4      \
4832                   -Wl,--wrap,avcodec_decode_video2      \
4833                   -Wl,--wrap,avcodec_decode_subtitle2   \
4834                   -Wl,--wrap,avcodec_encode_audio2      \
4835                   -Wl,--wrap,avcodec_encode_video2      \
4836                   -Wl,--wrap,avcodec_encode_subtitle    \
4837                   -Wl,--wrap,avresample_convert ||
4838     disable neon_clobber_test
4839
4840 enabled xmm_clobber_test &&
4841     check_ldflags -Wl,--wrap,avcodec_open2              \
4842                   -Wl,--wrap,avcodec_decode_audio4&n