You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4058 lines
119KB

  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. # Prevent locale nonsense from breaking basic text processing.
  10. LC_ALL=C
  11. export LC_ALL
  12. # make sure we are running under a compatible shell
  13. # try to make this part work with most shells
  14. try_exec(){
  15. echo "Trying shell $1"
  16. type "$1" > /dev/null 2>&1 && exec "$@"
  17. }
  18. unset foo
  19. (: ${foo%%bar}) 2> /dev/null
  20. E1="$?"
  21. (: ${foo?}) 2> /dev/null
  22. E2="$?"
  23. if test "$E1" != 0 || test "$E2" = 0; then
  24. echo "Broken shell detected. Trying alternatives."
  25. export FF_CONF_EXEC
  26. if test "0$FF_CONF_EXEC" -lt 1; then
  27. FF_CONF_EXEC=1
  28. try_exec bash "$0" "$@"
  29. fi
  30. if test "0$FF_CONF_EXEC" -lt 2; then
  31. FF_CONF_EXEC=2
  32. try_exec ksh "$0" "$@"
  33. fi
  34. if test "0$FF_CONF_EXEC" -lt 3; then
  35. FF_CONF_EXEC=3
  36. try_exec /usr/xpg4/bin/sh "$0" "$@"
  37. fi
  38. echo "No compatible shell script interpreter found."
  39. echo "This configure script requires a POSIX-compatible shell"
  40. echo "such as bash or ksh."
  41. echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH."
  42. echo "Instead, install a working POSIX-compatible shell."
  43. echo "Disabling this configure test will create a broken Libav."
  44. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  45. echo "This bash version ($BASH_VERSION) is broken on your platform."
  46. echo "Upgrade to a later version if available."
  47. fi
  48. exit 1
  49. fi
  50. test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
  51. show_help(){
  52. cat <<EOF
  53. Usage: configure [options]
  54. Options: [defaults in brackets after descriptions]
  55. Help options:
  56. --help print this message
  57. --list-decoders show all available decoders
  58. --list-encoders show all available encoders
  59. --list-hwaccels show all available hardware accelerators
  60. --list-demuxers show all available demuxers
  61. --list-muxers show all available muxers
  62. --list-parsers show all available parsers
  63. --list-protocols show all available protocols
  64. --list-bsfs show all available bitstream filters
  65. --list-indevs show all available input devices
  66. --list-outdevs show all available output devices
  67. --list-filters show all available filters
  68. Standard options:
  69. --logfile=FILE log tests and output to FILE [config.log]
  70. --disable-logging do not log configure debug information
  71. --prefix=PREFIX install in PREFIX [$prefix]
  72. --bindir=DIR install binaries in DIR [PREFIX/bin]
  73. --datadir=DIR install data files in DIR [PREFIX/share/avconv]
  74. --libdir=DIR install libs in DIR [PREFIX/lib]
  75. --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
  76. --incdir=DIR install includes in DIR [PREFIX/include]
  77. --mandir=DIR install man page in DIR [PREFIX/share/man]
  78. Licensing options:
  79. --enable-gpl allow use of GPL code, the resulting libs
  80. and binaries will be under GPL [no]
  81. --enable-version3 upgrade (L)GPL to version 3 [no]
  82. --enable-nonfree allow use of nonfree code, the resulting libs
  83. and binaries will be unredistributable [no]
  84. Configuration options:
  85. --disable-static do not build static libraries [no]
  86. --enable-shared build shared libraries [no]
  87. --enable-small optimize for size instead of speed
  88. --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
  89. --enable-gray enable full grayscale support (slower color)
  90. --disable-swscale-alpha disable alpha channel support in swscale
  91. --disable-all disable building components, libraries and programs
  92. Program options:
  93. --disable-programs do not build command line programs
  94. --disable-avconv disable avconv build
  95. --disable-avplay disable avplay build
  96. --disable-avprobe disable avprobe build
  97. --disable-avserver disable avserver build
  98. Component options:
  99. --disable-doc do not build documentation
  100. --disable-avdevice disable libavdevice build
  101. --disable-avcodec disable libavcodec build
  102. --disable-avformat disable libavformat build
  103. --disable-avutil disable libavutil build
  104. --disable-swscale disable libswscale build
  105. --disable-avfilter disable video filter support [no]
  106. --disable-avresample disable libavresample build [no]
  107. --disable-pthreads disable pthreads [auto]
  108. --disable-w32threads disable Win32 threads [auto]
  109. --enable-x11grab enable X11 grabbing [no]
  110. --disable-network disable network support [no]
  111. --disable-dct disable DCT code
  112. --disable-lsp disable LSP code
  113. --disable-lzo disable LZO decoder code
  114. --disable-mdct disable MDCT code
  115. --disable-rdft disable RDFT code
  116. --disable-fft disable FFT code
  117. --enable-dxva2 enable DXVA2 code
  118. --enable-vaapi enable VAAPI code
  119. --enable-vda enable VDA code
  120. --enable-vdpau enable VDPAU code
  121. Individual component options:
  122. --disable-everything disable all components listed below
  123. --disable-encoder=NAME disable encoder NAME
  124. --enable-encoder=NAME enable encoder NAME
  125. --disable-encoders disable all encoders
  126. --disable-decoder=NAME disable decoder NAME
  127. --enable-decoder=NAME enable decoder NAME
  128. --disable-decoders disable all decoders
  129. --disable-hwaccel=NAME disable hwaccel NAME
  130. --enable-hwaccel=NAME enable hwaccel NAME
  131. --disable-hwaccels disable all hwaccels
  132. --disable-muxer=NAME disable muxer NAME
  133. --enable-muxer=NAME enable muxer NAME
  134. --disable-muxers disable all muxers
  135. --disable-demuxer=NAME disable demuxer NAME
  136. --enable-demuxer=NAME enable demuxer NAME
  137. --disable-demuxers disable all demuxers
  138. --enable-parser=NAME enable parser NAME
  139. --disable-parser=NAME disable parser NAME
  140. --disable-parsers disable all parsers
  141. --enable-bsf=NAME enable bitstream filter NAME
  142. --disable-bsf=NAME disable bitstream filter NAME
  143. --disable-bsfs disable all bitstream filters
  144. --enable-protocol=NAME enable protocol NAME
  145. --disable-protocol=NAME disable protocol NAME
  146. --disable-protocols disable all protocols
  147. --enable-indev=NAME enable input device NAME
  148. --disable-indev=NAME disable input device NAME
  149. --disable-indevs disable input devices
  150. --enable-outdev=NAME enable output device NAME
  151. --disable-outdev=NAME disable output device NAME
  152. --disable-outdevs disable output devices
  153. --disable-devices disable all devices
  154. --enable-filter=NAME enable filter NAME
  155. --disable-filter=NAME disable filter NAME
  156. --disable-filters disable all filters
  157. External library support:
  158. --enable-avisynth enable reading of AVISynth script files [no]
  159. --enable-bzlib enable bzlib [autodetect]
  160. --enable-frei0r enable frei0r video filtering
  161. --enable-gnutls enable gnutls [no]
  162. --enable-libcdio enable audio CD grabbing with libcdio
  163. --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
  164. and libraw1394 [no]
  165. --enable-libfaac enable AAC encoding via libfaac [no]
  166. --enable-libfdk-aac enable AAC encoding via libfdk-aac [no]
  167. --enable-libfreetype enable libfreetype [no]
  168. --enable-libgsm enable GSM de/encoding via libgsm [no]
  169. --enable-libilbc enable iLBC de/encoding via libilbc [no]
  170. --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
  171. --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  172. --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  173. --enable-libopencv enable video filtering via libopencv [no]
  174. --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
  175. --enable-libopus enable Opus decoding via libopus [no]
  176. --enable-libpulse enable Pulseaudio input via libpulse [no]
  177. --enable-librtmp enable RTMP[E] support via librtmp [no]
  178. --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
  179. --enable-libspeex enable Speex de/encoding via libspeex [no]
  180. --enable-libtheora enable Theora encoding via libtheora [no]
  181. --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
  182. --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
  183. --enable-libvorbis enable Vorbis encoding via libvorbis [no]
  184. --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
  185. --enable-libx264 enable H.264 encoding via x264 [no]
  186. --enable-libxavs enable AVS encoding via xavs [no]
  187. --enable-libxvid enable Xvid encoding via xvidcore,
  188. native MPEG-4/Xvid encoder exists [no]
  189. --enable-openssl enable openssl [no]
  190. --enable-zlib enable zlib [autodetect]
  191. Advanced options (experts only):
  192. --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
  193. --enable-cross-compile assume a cross-compiler is used
  194. --sysroot=PATH root of cross-build tree
  195. --sysinclude=PATH location of cross-build system headers
  196. --target-os=OS compiler targets OS [$target_os]
  197. --target-exec=CMD command to run executables on target
  198. --target-path=DIR path to view of build directory on target
  199. --toolchain=NAME set tool defaults according to NAME
  200. --nm=NM use nm tool
  201. --ar=AR use archive tool AR [$ar_default]
  202. --as=AS use assembler AS [$as_default]
  203. --cc=CC use C compiler CC [$cc_default]
  204. --dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
  205. --ld=LD use linker LD
  206. --host-cc=HOSTCC use host C compiler HOSTCC
  207. --host-cflags=HCFLAGS use HCFLAGS when compiling for host
  208. --host-ld=HOSTLD use host linker HOSTLD
  209. --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
  210. --host-libs=HLIBS use libs HLIBS when linking for host
  211. --host-os=OS compiler host OS [$target_os]
  212. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
  213. --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
  214. --extra-libs=ELIBS add ELIBS [$ELIBS]
  215. --extra-version=STRING version string suffix []
  216. --optflags=OPTFLAGS override optimization-related compiler flags
  217. --build-suffix=SUFFIX library name suffix []
  218. --malloc-prefix=PREFIX prefix malloc and related names with PREFIX
  219. --arch=ARCH select architecture [$arch]
  220. --cpu=CPU select the minimum required CPU (affects
  221. instruction selection, may crash on older CPUs)
  222. --enable-pic build position-independent code
  223. --enable-sram allow use of on-chip SRAM
  224. --enable-thumb compile for Thumb instruction set
  225. --disable-symver disable symbol versioning
  226. --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  227. --disable-safe-bitstream-reader
  228. disable buffer boundary checking in bitreaders
  229. (faster, but may crash)
  230. --enable-memalign-hack emulate memalign, interferes with memory debuggers
  231. --enable-lto use link-time optimization
  232. Optimization options (experts only):
  233. --disable-asm disable all assembler optimizations
  234. --disable-altivec disable AltiVec optimizations
  235. --disable-amd3dnow disable 3DNow! optimizations
  236. --disable-amd3dnowext disable 3DNow! extended optimizations
  237. --disable-mmx disable MMX optimizations
  238. --disable-mmxext disable MMXEXT optimizations
  239. --disable-sse disable SSE optimizations
  240. --disable-sse2 disable SSE2 optimizations
  241. --disable-sse3 disable SSE3 optimizations
  242. --disable-ssse3 disable SSSE3 optimizations
  243. --disable-sse4 disable SSE4 optimizations
  244. --disable-sse42 disable SSE4.2 optimizations
  245. --disable-avx disable AVX optimizations
  246. --disable-fma4 disable FMA4 optimizations
  247. --disable-armv5te disable armv5te optimizations
  248. --disable-armv6 disable armv6 optimizations
  249. --disable-armv6t2 disable armv6t2 optimizations
  250. --disable-vfp disable VFP optimizations
  251. --disable-neon disable NEON optimizations
  252. --disable-vis disable VIS optimizations
  253. --disable-inline-asm disable use of inline assembler
  254. --disable-yasm disable use of yasm assembler
  255. Developer options (useful when working on Libav itself):
  256. --disable-debug disable debugging symbols
  257. --enable-debug=LEVEL set the debug level [$debuglevel]
  258. --disable-optimizations disable compiler optimizations
  259. --enable-extra-warnings enable more compiler warnings
  260. --samples=PATH location of test samples for FATE, if not set use
  261. \$LIBAV_SAMPLES at make invocation time.
  262. --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
  263. should be used only for debugging purposes)
  264. --enable-random randomly enable/disable components
  265. --disable-random
  266. --enable-random=LIST randomly enable/disable specific components or
  267. --disable-random=LIST component groups. LIST is a comma-separated list
  268. of NAME[:PROB] entries where NAME is a component
  269. (group) and PROB the probability associated with
  270. NAME (default 0.5).
  271. --random-seed=VALUE seed value for --enable/disable-random
  272. NOTE: Object files are built at the place where configure is launched.
  273. EOF
  274. exit 0
  275. }
  276. quotes='""'
  277. log(){
  278. echo "$@" >> $logfile
  279. }
  280. log_file(){
  281. log BEGIN $1
  282. pr -n -t $1 >> $logfile
  283. log END $1
  284. }
  285. echolog(){
  286. log "$@"
  287. echo "$@"
  288. }
  289. warn(){
  290. log "WARNING: $*"
  291. WARNINGS="${WARNINGS}WARNING: $*\n"
  292. }
  293. die(){
  294. echolog "$@"
  295. cat <<EOF
  296. If you think configure made a mistake, make sure you are using the latest
  297. version from Git. If the latest version fails, report the problem to the
  298. libav-user@libav.org mailing list or IRC #libav on irc.freenode.net.
  299. EOF
  300. if disabled logging; then
  301. cat <<EOF
  302. Rerun configure with logging enabled (do not use --disable-logging), and
  303. include the log this produces with your report.
  304. EOF
  305. else
  306. cat <<EOF
  307. Include the log file "$logfile" produced by configure as this will help
  308. solving the problem.
  309. EOF
  310. fi
  311. exit 1
  312. }
  313. # Avoid locale weirdness, besides we really just want to translate ASCII.
  314. toupper(){
  315. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  316. }
  317. tolower(){
  318. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  319. }
  320. c_escape(){
  321. echo "$*" | sed 's/["\\]/\\\0/g'
  322. }
  323. sh_quote(){
  324. v=$(echo "$1" | sed "s/'/'\\\\''/g")
  325. test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
  326. echo "$v"
  327. }
  328. cleanws(){
  329. echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
  330. }
  331. filter(){
  332. pat=$1
  333. shift
  334. for v; do
  335. eval "case $v in $pat) echo $v ;; esac"
  336. done
  337. }
  338. filter_out(){
  339. pat=$1
  340. shift
  341. for v; do
  342. eval "case $v in $pat) ;; *) echo $v ;; esac"
  343. done
  344. }
  345. map(){
  346. m=$1
  347. shift
  348. for v; do eval $m; done
  349. }
  350. add_suffix(){
  351. suffix=$1
  352. shift
  353. for v; do echo ${v}${suffix}; done
  354. }
  355. set_all(){
  356. value=$1
  357. shift
  358. for var in $*; do
  359. eval $var=$value
  360. done
  361. }
  362. set_weak(){
  363. value=$1
  364. shift
  365. for var; do
  366. eval : \${$var:=$value}
  367. done
  368. }
  369. set_safe(){
  370. var=$1
  371. shift
  372. eval $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')='$*'
  373. }
  374. get_safe(){
  375. eval echo \$$(echo "$1" | sed 's/[^A-Za-z0-9_]/_/g')
  376. }
  377. pushvar(){
  378. for var in $*; do
  379. eval level=\${${var}_level:=0}
  380. eval ${var}_${level}="\$$var"
  381. eval ${var}_level=$(($level+1))
  382. done
  383. }
  384. popvar(){
  385. for var in $*; do
  386. eval level=\${${var}_level:-0}
  387. test $level = 0 && continue
  388. eval level=$(($level-1))
  389. eval $var="\${${var}_${level}}"
  390. eval ${var}_level=$level
  391. eval unset ${var}_${level}
  392. done
  393. }
  394. enable(){
  395. set_all yes $*
  396. }
  397. disable(){
  398. set_all no $*
  399. }
  400. enable_weak(){
  401. set_weak yes $*
  402. }
  403. disable_weak(){
  404. set_weak no $*
  405. }
  406. enable_safe(){
  407. for var; do
  408. enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  409. done
  410. }
  411. disable_safe(){
  412. for var; do
  413. disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  414. done
  415. }
  416. do_enable_deep(){
  417. for var; do
  418. enabled $var && continue
  419. eval sel="\$${var}_select"
  420. eval sgs="\$${var}_suggest"
  421. pushvar var sgs
  422. enable_deep $sel
  423. popvar sgs
  424. enable_deep_weak $sgs
  425. popvar var
  426. done
  427. }
  428. enable_deep(){
  429. do_enable_deep $*
  430. enable $*
  431. }
  432. enable_deep_weak(){
  433. do_enable_deep $*
  434. enable_weak $*
  435. }
  436. enabled(){
  437. test "${1#!}" = "$1" && op== || op=!=
  438. eval test "x\$${1#!}" $op "xyes"
  439. }
  440. disabled(){
  441. test "${1#!}" = "$1" && op== || op=!=
  442. eval test "x\$${1#!}" $op "xno"
  443. }
  444. enabled_all(){
  445. for opt; do
  446. enabled $opt || return 1
  447. done
  448. }
  449. disabled_all(){
  450. for opt; do
  451. disabled $opt || return 1
  452. done
  453. }
  454. enabled_any(){
  455. for opt; do
  456. enabled $opt && return 0
  457. done
  458. }
  459. disabled_any(){
  460. for opt; do
  461. disabled $opt && return 0
  462. done
  463. return 1
  464. }
  465. set_default(){
  466. for opt; do
  467. eval : \${$opt:=\$${opt}_default}
  468. done
  469. }
  470. is_in(){
  471. value=$1
  472. shift
  473. for var in $*; do
  474. [ $var = $value ] && return 0
  475. done
  476. return 1
  477. }
  478. do_check_deps(){
  479. for cfg; do
  480. cfg="${cfg#!}"
  481. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  482. disabled ${cfg}_checking && continue
  483. enable ${cfg}_checking
  484. append allopts $cfg
  485. eval dep_all="\$${cfg}_deps"
  486. eval dep_any="\$${cfg}_deps_any"
  487. eval dep_sel="\$${cfg}_select"
  488. eval dep_sgs="\$${cfg}_suggest"
  489. eval dep_ifa="\$${cfg}_if"
  490. eval dep_ifn="\$${cfg}_if_any"
  491. pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  492. do_check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
  493. popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  494. [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
  495. [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
  496. enabled_all $dep_all || disable $cfg
  497. enabled_any $dep_any || disable $cfg
  498. disabled_any $dep_sel && disable $cfg
  499. if enabled $cfg; then
  500. enable_deep $dep_sel
  501. enable_deep_weak $dep_sgs
  502. fi
  503. disable ${cfg}_checking
  504. done
  505. }
  506. check_deps(){
  507. unset allopts
  508. do_check_deps "$@"
  509. for cfg in $allopts; do
  510. enabled $cfg || continue
  511. eval dep_extralibs="\$${cfg}_extralibs"
  512. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  513. done
  514. }
  515. print_config(){
  516. pfx=$1
  517. files=$2
  518. shift 2
  519. map 'eval echo "$v \${$v:-no}"' "$@" |
  520. awk "BEGIN { split(\"$files\", files) }
  521. {
  522. c = \"$pfx\" toupper(\$1);
  523. v = \$2;
  524. sub(/yes/, 1, v);
  525. sub(/no/, 0, v);
  526. for (f in files) {
  527. file = files[f];
  528. if (file ~ /\\.h\$/) {
  529. printf(\"#define %s %d\\n\", c, v) >>file;
  530. } else if (file ~ /\\.asm\$/) {
  531. printf(\"%%define %s %d\\n\", c, v) >>file;
  532. } else if (file ~ /\\.mak\$/) {
  533. n = -v ? \"\" : \"!\";
  534. printf(\"%s%s=yes\\n\", n, c) >>file;
  535. }
  536. }
  537. }"
  538. }
  539. print_enabled(){
  540. suf=$1
  541. shift
  542. for v; do
  543. enabled $v && printf "%s\n" ${v%$suf};
  544. done
  545. }
  546. append(){
  547. var=$1
  548. shift
  549. eval "$var=\"\$$var $*\""
  550. }
  551. prepend(){
  552. var=$1
  553. shift
  554. eval "$var=\"$* \$$var\""
  555. }
  556. add_cppflags(){
  557. append CPPFLAGS "$@"
  558. }
  559. add_cflags(){
  560. append CFLAGS $($cflags_filter "$@")
  561. }
  562. add_asflags(){
  563. append ASFLAGS $($asflags_filter "$@")
  564. }
  565. add_ldflags(){
  566. append LDFLAGS $($ldflags_filter "$@")
  567. }
  568. add_extralibs(){
  569. prepend extralibs $($ldflags_filter "$@")
  570. }
  571. add_host_cflags(){
  572. append host_cflags $($host_cflags_filter "$@")
  573. }
  574. add_host_ldflags(){
  575. append host_ldflags $($host_ldflags_filter "$@")
  576. }
  577. add_compat(){
  578. append compat_objs $1
  579. shift
  580. map 'add_cppflags -D$v' "$@"
  581. }
  582. check_cmd(){
  583. log "$@"
  584. "$@" >> $logfile 2>&1
  585. }
  586. cc_o(){
  587. eval printf '%s\\n' $CC_O
  588. }
  589. cc_e(){
  590. eval printf '%s\\n' $CC_E
  591. }
  592. check_cc(){
  593. log check_cc "$@"
  594. cat > $TMPC
  595. log_file $TMPC
  596. check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
  597. }
  598. check_cpp(){
  599. log check_cpp "$@"
  600. cat > $TMPC
  601. log_file $TMPC
  602. check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
  603. }
  604. as_o(){
  605. eval printf '%s\\n' $AS_O
  606. }
  607. check_as(){
  608. log check_as "$@"
  609. cat > $TMPS
  610. log_file $TMPS
  611. check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
  612. }
  613. check_inline_asm(){
  614. log check_inline_asm "$@"
  615. name="$1"
  616. code="$2"
  617. shift 2
  618. disable $name
  619. check_cc "$@" <<EOF && enable $name
  620. void foo(void){ __asm__ volatile($code); }
  621. EOF
  622. }
  623. check_insn(){
  624. log check_insn "$@"
  625. check_inline_asm ${1}_inline "\"$2\""
  626. echo "$2" | check_as && enable ${1}_external || disable ${1}_external
  627. }
  628. check_yasm(){
  629. log check_yasm "$@"
  630. echo "$1" > $TMPS
  631. log_file $TMPS
  632. shift 1
  633. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  634. }
  635. ld_o(){
  636. eval printf '%s\\n' $LD_O
  637. }
  638. check_ld(){
  639. log check_ld "$@"
  640. flags=$(filter_out '-l*' "$@")
  641. libs=$(filter '-l*' "$@")
  642. check_cc $($cflags_filter $flags) || return
  643. flags=$($ldflags_filter $flags)
  644. libs=$($ldflags_filter $libs)
  645. check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
  646. }
  647. check_code(){
  648. log check_code "$@"
  649. check=$1
  650. headers=$2
  651. code=$3
  652. shift 3
  653. {
  654. for hdr in $headers; do
  655. echo "#include <$hdr>"
  656. done
  657. echo "int main(void) { $code; return 0; }"
  658. } | check_$check "$@"
  659. }
  660. check_cppflags(){
  661. log check_cppflags "$@"
  662. check_cc "$@" <<EOF && append CPPFLAGS "$@"
  663. int x;
  664. EOF
  665. }
  666. check_cflags(){
  667. log check_cflags "$@"
  668. set -- $($cflags_filter "$@")
  669. check_cc "$@" <<EOF && append CFLAGS "$@"
  670. int x;
  671. EOF
  672. }
  673. test_ldflags(){
  674. log test_ldflags "$@"
  675. check_ld "$@" <<EOF
  676. int main(void){ return 0; }
  677. EOF
  678. }
  679. check_ldflags(){
  680. log check_ldflags "$@"
  681. test_ldflags "$@" && add_ldflags "$@"
  682. }
  683. check_header(){
  684. log check_header "$@"
  685. header=$1
  686. shift
  687. disable_safe $header
  688. check_cpp "$@" <<EOF && enable_safe $header
  689. #include <$header>
  690. int x;
  691. EOF
  692. }
  693. check_func(){
  694. log check_func "$@"
  695. func=$1
  696. shift
  697. disable $func
  698. check_ld "$@" <<EOF && enable $func
  699. extern int $func();
  700. int main(void){ $func(); }
  701. EOF
  702. }
  703. check_mathfunc(){
  704. log check_mathfunc "$@"
  705. func=$1
  706. narg=$2
  707. shift 2
  708. test $narg = 2 && args="f, g" || args="f"
  709. disable $func
  710. check_ld "$@" <<EOF && enable $func
  711. #include <math.h>
  712. float foo(float f, float g) { return $func($args); }
  713. int main(void){ return 0; }
  714. EOF
  715. }
  716. check_func_headers(){
  717. log check_func_headers "$@"
  718. headers=$1
  719. funcs=$2
  720. shift 2
  721. {
  722. for hdr in $headers; do
  723. echo "#include <$hdr>"
  724. done
  725. for func in $funcs; do
  726. echo "long check_$func(void) { return (long) $func; }"
  727. done
  728. echo "int main(void) { return 0; }"
  729. } | check_ld "$@" && enable $funcs && enable_safe $headers
  730. }
  731. check_cpp_condition(){
  732. log check_cpp_condition "$@"
  733. header=$1
  734. condition=$2
  735. shift 2
  736. check_cpp "$@" <<EOF
  737. #include <$header>
  738. #if !($condition)
  739. #error "unsatisfied condition: $condition"
  740. #endif
  741. EOF
  742. }
  743. check_lib(){
  744. log check_lib "$@"
  745. header="$1"
  746. func="$2"
  747. shift 2
  748. check_header $header && check_func $func "$@" && add_extralibs "$@"
  749. }
  750. check_lib2(){
  751. log check_lib2 "$@"
  752. headers="$1"
  753. funcs="$2"
  754. shift 2
  755. check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
  756. }
  757. check_pkg_config(){
  758. log check_pkg_config "$@"
  759. pkg="$1"
  760. headers="$2"
  761. funcs="$3"
  762. shift 3
  763. $pkg_config --exists $pkg || return
  764. pkg_cflags=$($pkg_config --cflags $pkg)
  765. pkg_libs=$($pkg_config --libs $pkg)
  766. check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
  767. set_safe ${pkg}_cflags $pkg_cflags &&
  768. set_safe ${pkg}_libs $pkg_libs
  769. }
  770. check_exec(){
  771. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  772. }
  773. check_exec_crash(){
  774. code=$(cat)
  775. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  776. # are safe but may not be available everywhere. Thus we use
  777. # raise(SIGTERM) instead. The check is run in a subshell so we
  778. # can redirect the "Terminated" message from the shell. SIGBUS
  779. # is not defined by standard C so it is used conditionally.
  780. (check_exec "$@") >> $logfile 2>&1 <<EOF
  781. #include <signal.h>
  782. static void sighandler(int sig){
  783. raise(SIGTERM);
  784. }
  785. int foo(void){
  786. $code
  787. }
  788. int main(void){
  789. signal(SIGILL, sighandler);
  790. signal(SIGFPE, sighandler);
  791. signal(SIGSEGV, sighandler);
  792. #ifdef SIGBUS
  793. signal(SIGBUS, sighandler);
  794. #endif
  795. foo();
  796. }
  797. EOF
  798. }
  799. check_type(){
  800. log check_type "$@"
  801. headers=$1
  802. type=$2
  803. shift 2
  804. disable_safe "$type"
  805. check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
  806. }
  807. check_struct(){
  808. log check_type "$@"
  809. headers=$1
  810. struct=$2
  811. member=$3
  812. shift 3
  813. disable_safe "${struct}_${member}"
  814. check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
  815. enable_safe "${struct}_${member}"
  816. }
  817. require(){
  818. name="$1"
  819. header="$2"
  820. func="$3"
  821. shift 3
  822. check_lib $header $func "$@" || die "ERROR: $name not found"
  823. }
  824. require2(){
  825. name="$1"
  826. headers="$2"
  827. func="$3"
  828. shift 3
  829. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  830. }
  831. require_pkg_config(){
  832. pkg="$1"
  833. check_pkg_config "$@" || die "ERROR: $pkg not found"
  834. add_cflags $(get_safe ${pkg}_cflags)
  835. add_extralibs $(get_safe ${pkg}_libs)
  836. }
  837. hostcc_o(){
  838. eval printf '%s\\n' $HOSTCC_O
  839. }
  840. check_host_cc(){
  841. log check_host_cc "$@"
  842. cat > $TMPC
  843. log_file $TMPC
  844. check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
  845. }
  846. check_host_cflags(){
  847. log check_host_cflags "$@"
  848. set -- $($host_cflags_filter "$@")
  849. check_host_cc "$@" <<EOF && append host_cflags "$@"
  850. int x;
  851. EOF
  852. }
  853. apply(){
  854. file=$1
  855. shift
  856. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  857. }
  858. cp_if_changed(){
  859. cmp -s "$1" "$2" && echo "$2 is unchanged" && return
  860. mkdir -p "$(dirname $2)"
  861. $cp_f "$1" "$2"
  862. }
  863. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  864. # system-dependent things.
  865. COMPONENT_LIST="
  866. bsfs
  867. decoders
  868. demuxers
  869. encoders
  870. filters
  871. hwaccels
  872. indevs
  873. muxers
  874. outdevs
  875. parsers
  876. protocols
  877. "
  878. LIBRARY_LIST="
  879. avcodec
  880. avdevice
  881. avfilter
  882. avformat
  883. avresample
  884. avutil
  885. swscale
  886. "
  887. PROGRAM_LIST="
  888. avconv
  889. avplay
  890. avprobe
  891. avserver
  892. "
  893. CONFIG_LIST="
  894. $COMPONENT_LIST
  895. $LIBRARY_LIST
  896. $PROGRAM_LIST
  897. avisynth
  898. bzlib
  899. dct
  900. doc
  901. dxva2
  902. fft
  903. frei0r
  904. gnutls
  905. gpl
  906. gray
  907. hardcoded_tables
  908. libcdio
  909. libdc1394
  910. libfaac
  911. libfdk_aac
  912. libfreetype
  913. libgsm
  914. libilbc
  915. libmp3lame
  916. libopencore_amrnb
  917. libopencore_amrwb
  918. libopencv
  919. libopenjpeg
  920. libopus
  921. libpulse
  922. librtmp
  923. libschroedinger
  924. libspeex
  925. libtheora
  926. libvo_aacenc
  927. libvo_amrwbenc
  928. libvorbis
  929. libvpx
  930. libx264
  931. libxavs
  932. libxvid
  933. lsp
  934. lzo
  935. mdct
  936. memalign_hack
  937. network
  938. nonfree
  939. openssl
  940. pic
  941. rdft
  942. runtime_cpudetect
  943. safe_bitstream_reader
  944. shared
  945. small
  946. sram
  947. static
  948. swscale_alpha
  949. thumb
  950. vaapi
  951. vda
  952. vdpau
  953. version3
  954. xmm_clobber_test
  955. x11grab
  956. zlib
  957. "
  958. THREADS_LIST='
  959. pthreads
  960. w32threads
  961. '
  962. ARCH_LIST='
  963. aarch64
  964. alpha
  965. arm
  966. avr32
  967. avr32_ap
  968. avr32_uc
  969. bfin
  970. ia64
  971. m68k
  972. mips
  973. mips64
  974. parisc
  975. ppc
  976. ppc64
  977. s390
  978. sh4
  979. sparc
  980. sparc64
  981. tilegx
  982. tilepro
  983. tomi
  984. x86
  985. x86_32
  986. x86_64
  987. '
  988. ARCH_EXT_LIST_ARM='
  989. armv5te
  990. armv6
  991. armv6t2
  992. neon
  993. vfp
  994. vfpv3
  995. '
  996. ARCH_EXT_LIST_X86='
  997. amd3dnow
  998. amd3dnowext
  999. avx
  1000. fma4
  1001. mmx
  1002. mmxext
  1003. sse
  1004. sse2
  1005. sse3
  1006. sse4
  1007. sse42
  1008. ssse3
  1009. '
  1010. ARCH_EXT_LIST="
  1011. $ARCH_EXT_LIST_ARM
  1012. $ARCH_EXT_LIST_X86
  1013. altivec
  1014. ppc4xx
  1015. vis
  1016. "
  1017. HAVE_LIST_CMDLINE='
  1018. inline_asm
  1019. symver
  1020. yasm
  1021. '
  1022. HAVE_LIST_PUB='
  1023. bigendian
  1024. fast_unaligned
  1025. '
  1026. MATH_FUNCS="
  1027. atanf
  1028. atan2f
  1029. cbrtf
  1030. cosf
  1031. exp2
  1032. exp2f
  1033. expf
  1034. isinf
  1035. isnan
  1036. ldexpf
  1037. llrint
  1038. llrintf
  1039. log2
  1040. log2f
  1041. log10f
  1042. lrint
  1043. lrintf
  1044. powf
  1045. rint
  1046. round
  1047. roundf
  1048. sinf
  1049. trunc
  1050. truncf
  1051. "
  1052. HAVE_LIST="
  1053. $ARCH_EXT_LIST
  1054. $(add_suffix _external $ARCH_EXT_LIST)
  1055. $(add_suffix _inline $ARCH_EXT_LIST)
  1056. $HAVE_LIST_CMDLINE
  1057. $HAVE_LIST_PUB
  1058. $THREADS_LIST
  1059. $MATH_FUNCS
  1060. aligned_malloc
  1061. aligned_stack
  1062. alsa_asoundlib_h
  1063. altivec_h
  1064. arpa_inet_h
  1065. asm_mod_q
  1066. asm_mod_y
  1067. attribute_may_alias
  1068. attribute_packed
  1069. cdio_paranoia_h
  1070. cdio_paranoia_paranoia_h
  1071. closesocket
  1072. cmov
  1073. CommandLineToArgvW
  1074. cpunop
  1075. CryptGenRandom
  1076. dcbzl
  1077. dev_bktr_ioctl_bt848_h
  1078. dev_bktr_ioctl_meteor_h
  1079. dev_ic_bt8xx_h
  1080. dev_video_bktr_ioctl_bt848_h
  1081. dev_video_meteor_ioctl_meteor_h
  1082. direct_h
  1083. dlfcn_h
  1084. dlopen
  1085. dos_paths
  1086. dxva_h
  1087. ebp_available
  1088. ebx_available
  1089. fast_64bit
  1090. fast_clz
  1091. fast_cmov
  1092. fcntl
  1093. fork
  1094. getaddrinfo
  1095. gethrtime
  1096. getopt
  1097. GetProcessAffinityMask
  1098. GetProcessMemoryInfo
  1099. GetProcessTimes
  1100. GetSystemTimeAsFileTime
  1101. getrusage
  1102. getservbyport
  1103. gettimeofday
  1104. gnu_as
  1105. gsm_h
  1106. ibm_asm
  1107. inet_aton
  1108. io_h
  1109. isatty
  1110. jack_port_get_latency_range
  1111. ldbrx
  1112. libdc1394_1
  1113. libdc1394_2
  1114. local_aligned_16
  1115. local_aligned_8
  1116. localtime_r
  1117. loongson
  1118. machine_ioctl_bt848_h
  1119. machine_ioctl_meteor_h
  1120. malloc_h
  1121. MapViewOfFile
  1122. memalign
  1123. mkstemp
  1124. mm_empty
  1125. mmap
  1126. mprotect
  1127. msvcrt
  1128. nanosleep
  1129. poll_h
  1130. posix_memalign
  1131. rdtsc
  1132. sched_getaffinity
  1133. sdl
  1134. sdl_video_size
  1135. SetConsoleTextAttribute
  1136. setmode
  1137. setrlimit
  1138. Sleep
  1139. sndio_h
  1140. socklen_t
  1141. soundcard_h
  1142. strerror_r
  1143. strptime
  1144. strtok_r
  1145. struct_addrinfo
  1146. struct_group_source_req
  1147. struct_ip_mreq_source
  1148. struct_ipv6_mreq
  1149. struct_pollfd
  1150. struct_rusage_ru_maxrss
  1151. struct_sockaddr_in6
  1152. struct_sockaddr_sa_len
  1153. struct_sockaddr_storage
  1154. struct_v4l2_frmivalenum_discrete
  1155. symver_asm_label
  1156. symver_gnu_asm
  1157. sysconf
  1158. sysctl
  1159. sys_mman_h
  1160. sys_param_h
  1161. sys_resource_h
  1162. sys_select_h
  1163. sys_soundcard_h
  1164. sys_time_h
  1165. sys_videoio_h
  1166. threads
  1167. unistd_h
  1168. usleep
  1169. vfp_args
  1170. VirtualAlloc
  1171. windows_h
  1172. winsock2_h
  1173. xform_asm
  1174. xmm_clobbers
  1175. "
  1176. # options emitted with CONFIG_ prefix but not available on the command line
  1177. CONFIG_EXTRA="
  1178. aandcttables
  1179. ac3dsp
  1180. error_resilience
  1181. gcrypt
  1182. golomb
  1183. gplv3
  1184. h264chroma
  1185. h264dsp
  1186. h264pred
  1187. h264qpel
  1188. huffman
  1189. lgplv3
  1190. lpc
  1191. mpegaudio
  1192. mpegaudiodsp
  1193. mpegvideo
  1194. mpegvideoenc
  1195. nettle
  1196. rangecoder
  1197. rtpdec
  1198. rtpenc_chain
  1199. sinewin
  1200. videodsp
  1201. vp3dsp
  1202. "
  1203. CMDLINE_SELECT="
  1204. $ARCH_EXT_LIST
  1205. $CONFIG_LIST
  1206. $HAVE_LIST_CMDLINE
  1207. $THREADS_LIST
  1208. asm
  1209. cross_compile
  1210. debug
  1211. extra_warnings
  1212. logging
  1213. lto
  1214. optimizations
  1215. "
  1216. PATHS_LIST='
  1217. bindir
  1218. datadir
  1219. incdir
  1220. libdir
  1221. mandir
  1222. prefix
  1223. shlibdir
  1224. '
  1225. CMDLINE_SET="
  1226. $PATHS_LIST
  1227. ar
  1228. arch
  1229. as
  1230. build_suffix
  1231. cc
  1232. cpu
  1233. cross_prefix
  1234. dep_cc
  1235. extra_version
  1236. host_cc
  1237. host_cflags
  1238. host_ld
  1239. host_ldflags
  1240. host_libs
  1241. host_os
  1242. ld
  1243. logfile
  1244. malloc_prefix
  1245. nm
  1246. optflags
  1247. pkg_config
  1248. random_seed
  1249. samples
  1250. sysinclude
  1251. sysroot
  1252. target_exec
  1253. target_os
  1254. target_path
  1255. toolchain
  1256. "
  1257. CMDLINE_APPEND="
  1258. extra_cflags
  1259. "
  1260. # code dependency declarations
  1261. # architecture extensions
  1262. armv5te_deps="arm"
  1263. armv6_deps="arm"
  1264. armv6t2_deps="arm"
  1265. neon_deps="arm"
  1266. vfp_deps="arm"
  1267. vfpv3_deps="vfp"
  1268. map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
  1269. altivec_deps="ppc"
  1270. ppc4xx_deps="ppc"
  1271. vis_deps="sparc"
  1272. x86_64_suggest="cmov fast_cmov"
  1273. amd3dnow_deps="mmx"
  1274. amd3dnowext_deps="amd3dnow"
  1275. mmx_deps="x86"
  1276. mmxext_deps="mmx"
  1277. sse_deps="mmxext"
  1278. sse2_deps="sse"
  1279. sse3_deps="sse2"
  1280. ssse3_deps="sse3"
  1281. sse4_deps="ssse3"
  1282. sse42_deps="sse4"
  1283. avx_deps="sse42"
  1284. fma4_deps="avx"
  1285. mmx_external_deps="yasm"
  1286. mmx_inline_deps="inline_asm"
  1287. mmx_suggest="mmx_external mmx_inline"
  1288. for ext in $(filter_out mmx $ARCH_EXT_LIST_X86); do
  1289. eval dep=\$${ext}_deps
  1290. eval ${ext}_external_deps='"${dep}_external"'
  1291. eval ${ext}_inline_deps='"${dep}_inline"'
  1292. eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
  1293. done
  1294. aligned_stack_if_any="ppc x86"
  1295. fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
  1296. fast_clz_if_any="alpha avr32 mips ppc x86"
  1297. fast_unaligned_if_any="ppc x86"
  1298. inline_asm_deps="!tms470"
  1299. need_memalign="altivec neon sse"
  1300. symver_if_any="symver_asm_label symver_gnu_asm"
  1301. log2_deps="!msvcrt"
  1302. # subsystems
  1303. dct_select="rdft"
  1304. mdct_select="fft"
  1305. rdft_select="fft"
  1306. mpegaudio_select="mpegaudiodsp"
  1307. mpegaudiodsp_select="dct"
  1308. mpegvideo_select="videodsp"
  1309. mpegvideoenc_select="mpegvideo"
  1310. # decoders / encoders
  1311. aac_decoder_select="mdct sinewin"
  1312. aac_encoder_select="mdct sinewin"
  1313. aac_latm_decoder_select="aac_decoder aac_latm_parser"
  1314. ac3_decoder_select="mdct ac3dsp ac3_parser"
  1315. ac3_encoder_select="mdct ac3dsp"
  1316. ac3_fixed_encoder_select="mdct ac3dsp"
  1317. alac_encoder_select="lpc"
  1318. amrnb_decoder_select="lsp"
  1319. amrwb_decoder_select="lsp"
  1320. atrac1_decoder_select="mdct sinewin"
  1321. atrac3_decoder_select="mdct"
  1322. binkaudio_dct_decoder_select="mdct rdft dct sinewin"
  1323. binkaudio_rdft_decoder_select="mdct rdft sinewin"
  1324. cavs_decoder_select="golomb mpegvideo"
  1325. comfortnoise_encoder_select="lpc"
  1326. cook_decoder_select="mdct sinewin"
  1327. cscd_decoder_select="lzo"
  1328. cscd_decoder_suggest="zlib"
  1329. dca_decoder_select="mdct"
  1330. dnxhd_encoder_select="aandcttables mpegvideoenc"
  1331. dxa_decoder_select="zlib"
  1332. eac3_decoder_select="ac3_decoder"
  1333. eac3_encoder_select="ac3_encoder"
  1334. eamad_decoder_select="aandcttables error_resilience mpegvideo"
  1335. eatgq_decoder_select="aandcttables"
  1336. eatqi_decoder_select="aandcttables error_resilience mpegvideo"
  1337. ffv1_decoder_select="golomb rangecoder"
  1338. ffv1_encoder_select="rangecoder"
  1339. ffvhuff_encoder_select="huffman"
  1340. flac_decoder_select="golomb"
  1341. flac_encoder_select="golomb lpc"
  1342. flashsv_decoder_select="zlib"
  1343. flashsv_encoder_select="zlib"
  1344. flashsv2_decoder_select="zlib"
  1345. flv_decoder_select="h263_decoder"
  1346. flv_encoder_select="h263_encoder"
  1347. fraps_decoder_select="huffman"
  1348. h261_decoder_select="error_resilience mpegvideo"
  1349. h261_encoder_select="aandcttables mpegvideoenc"
  1350. h263_decoder_select="error_resilience h263_parser mpegvideo"
  1351. h263_encoder_select="aandcttables error_resilience mpegvideoenc"
  1352. h263i_decoder_select="h263_decoder"
  1353. h263p_encoder_select="h263_encoder"
  1354. h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  1355. huffyuv_encoder_select="huffman"
  1356. iac_decoder_select="fft mdct sinewin"
  1357. imc_decoder_select="fft mdct sinewin"
  1358. jpegls_decoder_select="golomb"
  1359. jpegls_encoder_select="golomb"
  1360. ljpeg_encoder_select="aandcttables mpegvideoenc"
  1361. loco_decoder_select="golomb"
  1362. mdec_decoder_select="error_resilience mpegvideo"
  1363. mjpeg_encoder_select="aandcttables mpegvideoenc"
  1364. mlp_decoder_select="mlp_parser"
  1365. mp1_decoder_select="mpegaudio"
  1366. mp1float_decoder_select="mpegaudio"
  1367. mp2_decoder_select="mpegaudio"
  1368. mp2float_decoder_select="mpegaudio"
  1369. mp3_decoder_select="mpegaudio"
  1370. mp3adu_decoder_select="mpegaudio"
  1371. mp3adufloat_decoder_select="mpegaudio"
  1372. mp3float_decoder_select="mpegaudio"
  1373. mp3on4_decoder_select="mpegaudio"
  1374. mp3on4float_decoder_select="mpegaudio"
  1375. mpc7_decoder_select="mpegaudiodsp"
  1376. mpc8_decoder_select="mpegaudiodsp"
  1377. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  1378. mpeg_xvmc_decoder_select="mpegvideo_decoder"
  1379. mpeg1video_decoder_select="error_resilience mpegvideo"
  1380. mpeg1video_encoder_select="aandcttables error_resilience mpegvideoenc"
  1381. mpeg2video_decoder_select="error_resilience mpegvideo"
  1382. mpeg2video_encoder_select="aandcttables error_resilience mpegvideoenc"
  1383. mpeg4_decoder_select="h263_decoder mpeg4video_parser"
  1384. mpeg4_encoder_select="h263_encoder"
  1385. msmpeg4v1_decoder_select="h263_decoder"
  1386. msmpeg4v1_encoder_select="h263_encoder"
  1387. msmpeg4v2_decoder_select="h263_decoder"
  1388. msmpeg4v2_encoder_select="h263_encoder"
  1389. msmpeg4v3_decoder_select="h263_decoder"
  1390. msmpeg4v3_encoder_select="h263_encoder"
  1391. mss2_decoder_select="vc1_decoder"
  1392. nellymoser_decoder_select="mdct sinewin"
  1393. nellymoser_encoder_select="mdct sinewin"
  1394. nuv_decoder_select="lzo"
  1395. png_decoder_select="zlib"
  1396. png_encoder_select="zlib"
  1397. qcelp_decoder_select="lsp"
  1398. qdm2_decoder_select="mdct rdft mpegaudiodsp"
  1399. ra_144_encoder_select="lpc"
  1400. ralf_decoder_select="golomb"
  1401. rv10_decoder_select="h263_decoder"
  1402. rv10_encoder_select="h263_encoder"
  1403. rv20_decoder_select="h263_decoder"
  1404. rv20_encoder_select="h263_encoder"
  1405. rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
  1406. rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
  1407. shorten_decoder_select="golomb"
  1408. sipr_decoder_select="lsp"
  1409. svq1_decoder_select="error_resilience mpegvideo"
  1410. svq1_encoder_select="aandcttables error_resilience mpegvideoenc"
  1411. svq3_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  1412. svq3_decoder_suggest="zlib"
  1413. theora_decoder_select="vp3_decoder"
  1414. tiff_decoder_suggest="zlib"
  1415. tiff_encoder_suggest="zlib"
  1416. truehd_decoder_select="mlp_decoder"
  1417. tscc_decoder_select="zlib"
  1418. twinvq_decoder_select="mdct lsp sinewin"
  1419. utvideo_encoder_select="huffman"
  1420. vc1_decoder_select="h263_decoder h264chroma h264qpel"
  1421. vc1image_decoder_select="vc1_decoder"
  1422. vorbis_decoder_select="mdct"
  1423. vorbis_encoder_select="mdct"
  1424. vp3_decoder_select="vp3dsp videodsp"
  1425. vp5_decoder_select="vp3dsp videodsp"
  1426. vp6_decoder_select="huffman vp3dsp videodsp"
  1427. vp6a_decoder_select="vp6_decoder"
  1428. vp6f_decoder_select="vp6_decoder"
  1429. vp8_decoder_select="h264pred videodsp"
  1430. wmapro_decoder_select="mdct sinewin"
  1431. wmav1_decoder_select="mdct sinewin"
  1432. wmav1_encoder_select="mdct sinewin"
  1433. wmav2_decoder_select="mdct sinewin"
  1434. wmav2_encoder_select="mdct sinewin"
  1435. wmavoice_decoder_select="lsp rdft dct mdct sinewin"
  1436. wmv1_decoder_select="h263_decoder"
  1437. wmv1_encoder_select="h263_encoder"
  1438. wmv2_decoder_select="h263_decoder"
  1439. wmv2_encoder_select="h263_encoder"
  1440. wmv3_decoder_select="vc1_decoder"
  1441. wmv3image_decoder_select="wmv3_decoder"
  1442. zerocodec_decoder_select="zlib"
  1443. zlib_decoder_select="zlib"
  1444. zlib_encoder_select="zlib"
  1445. zmbv_decoder_select="zlib"
  1446. zmbv_encoder_select="zlib"
  1447. # hardware accelerators
  1448. vaapi_deps="va_va_h"
  1449. vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
  1450. vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1451. h263_vaapi_hwaccel_select="vaapi h263_decoder"
  1452. h263_vdpau_hwaccel_select="vdpau h263_decoder"
  1453. h264_dxva2_hwaccel_deps="dxva2api_h"
  1454. h264_dxva2_hwaccel_select="dxva2 h264_decoder"
  1455. h264_vaapi_hwaccel_select="vaapi h264_decoder"
  1456. h264_vda_hwaccel_select="vda h264_decoder"
  1457. h264_vdpau_decoder_select="vdpau h264_decoder"
  1458. h264_vdpau_hwaccel_select="vdpau h264_decoder"
  1459. mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
  1460. mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
  1461. mpeg1_vdpau_hwaccel_select="vdpau mpeg1video_decoder"
  1462. mpeg2_dxva2_hwaccel_deps="dxva2api_h"
  1463. mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
  1464. mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
  1465. mpeg2_vdpau_hwaccel_select="vdpau mpeg2video_decoder"
  1466. mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
  1467. mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
  1468. mpeg4_vdpau_hwaccel_select="vdpau mpeg4_decoder"
  1469. vc1_dxva2_hwaccel_deps="dxva2api_h"
  1470. vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
  1471. vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
  1472. vc1_vdpau_decoder_select="vdpau vc1_decoder"
  1473. vc1_vdpau_hwaccel_select="vdpau vc1_decoder"
  1474. wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
  1475. wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
  1476. wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
  1477. wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
  1478. # parsers
  1479. h264_parser_select="error_resilience golomb h264dsp h264pred h264qpel mpegvideo"
  1480. mpeg4video_parser_select="error_resilience mpegvideo"
  1481. mpegvideo_parser_select="error_resilience mpegvideo"
  1482. vc1_parser_select="error_resilience mpegvideo"
  1483. # external libraries
  1484. libfaac_encoder_deps="libfaac"
  1485. libfdk_aac_encoder_deps="libfdk_aac"
  1486. libgsm_decoder_deps="libgsm"
  1487. libgsm_encoder_deps="libgsm"
  1488. libgsm_ms_decoder_deps="libgsm"
  1489. libgsm_ms_encoder_deps="libgsm"
  1490. libilbc_decoder_deps="libilbc"
  1491. libilbc_encoder_deps="libilbc"
  1492. libmp3lame_encoder_deps="libmp3lame"
  1493. libopencore_amrnb_decoder_deps="libopencore_amrnb"
  1494. libopencore_amrnb_encoder_deps="libopencore_amrnb"
  1495. libopencore_amrwb_decoder_deps="libopencore_amrwb"
  1496. libopenjpeg_decoder_deps="libopenjpeg"
  1497. libopenjpeg_encoder_deps="libopenjpeg"
  1498. libopus_decoder_deps="libopus"
  1499. libopus_encoder_deps="libopus"
  1500. libschroedinger_decoder_deps="libschroedinger"
  1501. libschroedinger_encoder_deps="libschroedinger"
  1502. libspeex_decoder_deps="libspeex"
  1503. libspeex_encoder_deps="libspeex"
  1504. libtheora_encoder_deps="libtheora"
  1505. libvo_aacenc_encoder_deps="libvo_aacenc"
  1506. libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
  1507. libvorbis_encoder_deps="libvorbis"
  1508. libvpx_vp8_decoder_deps="libvpx"
  1509. libvpx_vp8_encoder_deps="libvpx"
  1510. libvpx_vp9_decoder_deps="libvpx"
  1511. libvpx_vp9_encoder_deps="libvpx"
  1512. libx264_encoder_deps="libx264"
  1513. libxavs_encoder_deps="libxavs"
  1514. libxvid_encoder_deps="libxvid"
  1515. # demuxers / muxers
  1516. ac3_demuxer_select="ac3_parser"
  1517. asf_stream_muxer_select="asf_muxer"
  1518. avisynth_demuxer_deps="avisynth"
  1519. dirac_demuxer_select="dirac_parser"
  1520. eac3_demuxer_select="ac3_parser"
  1521. flac_demuxer_select="flac_parser"
  1522. ipod_muxer_select="mov_muxer"
  1523. ismv_muxer_select="mov_muxer"
  1524. matroska_audio_muxer_select="matroska_muxer"
  1525. matroska_demuxer_suggest="bzlib lzo zlib"
  1526. mov_demuxer_suggest="zlib"
  1527. mov_muxer_select="rtpenc_chain"
  1528. mp3_demuxer_select="mpegaudio_parser"
  1529. mp4_muxer_select="mov_muxer"
  1530. mpegts_muxer_select="adts_muxer latm_muxer mpegvideo"
  1531. mpegtsraw_demuxer_select="mpegts_demuxer"
  1532. mxf_d10_muxer_select="mxf_muxer"
  1533. ogg_demuxer_select="golomb"
  1534. psp_muxer_select="mov_muxer"
  1535. rtp_demuxer_select="sdp_demuxer"
  1536. rtp_muxer_select="mpegvideo"
  1537. rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
  1538. rtsp_demuxer_select="http_protocol rtpdec"
  1539. rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
  1540. sap_demuxer_select="sdp_demuxer"
  1541. sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
  1542. sdp_demuxer_select="rtpdec"
  1543. smoothstreaming_muxer_select="ismv_muxer"
  1544. spdif_muxer_select="aac_parser"
  1545. tak_demuxer_select="tak_parser"
  1546. tg2_muxer_select="mov_muxer"
  1547. tgp_muxer_select="mov_muxer"
  1548. w64_demuxer_deps="wav_demuxer"
  1549. # indevs / outdevs
  1550. alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1551. alsa_outdev_deps="alsa_asoundlib_h"
  1552. bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1553. dv1394_indev_deps="dv1394 dv_demuxer"
  1554. fbdev_indev_deps="linux_fb_h"
  1555. jack_indev_deps="jack_jack_h"
  1556. libcdio_indev_deps="libcdio"
  1557. libdc1394_indev_deps="libdc1394"
  1558. oss_indev_deps_any="soundcard_h sys_soundcard_h"
  1559. oss_outdev_deps_any="soundcard_h sys_soundcard_h"
  1560. pulse_indev_deps="libpulse"
  1561. sndio_indev_deps="sndio_h"
  1562. sndio_outdev_deps="sndio_h"
  1563. v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
  1564. vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
  1565. vfwcap_indev_extralibs="-lavicap32"
  1566. x11grab_indev_deps="x11grab XShmCreateImage"
  1567. # protocols
  1568. ffrtmpcrypt_protocol_deps="!librtmp_protocol"
  1569. ffrtmpcrypt_protocol_deps_any="gcrypt nettle openssl"
  1570. ffrtmpcrypt_protocol_select="tcp_protocol"
  1571. ffrtmphttp_protocol_deps="!librtmp_protocol"
  1572. ffrtmphttp_protocol_select="http_protocol"
  1573. gopher_protocol_select="network"
  1574. httpproxy_protocol_select="tcp_protocol"
  1575. http_protocol_select="tcp_protocol"
  1576. https_protocol_select="tls_protocol"
  1577. librtmp_protocol_deps="librtmp"
  1578. librtmpe_protocol_deps="librtmp"
  1579. librtmps_protocol_deps="librtmp"
  1580. librtmpt_protocol_deps="librtmp"
  1581. librtmpte_protocol_deps="librtmp"
  1582. mmsh_protocol_select="http_protocol"
  1583. mmst_protocol_select="network"
  1584. rtmp_protocol_deps="!librtmp_protocol"
  1585. rtmp_protocol_select="tcp_protocol"
  1586. rtmpe_protocol_select="ffrtmpcrypt_protocol"
  1587. rtmps_protocol_deps="!librtmp_protocol"
  1588. rtmps_protocol_select="tls_protocol"
  1589. rtmpt_protocol_select="ffrtmphttp_protocol"
  1590. rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
  1591. rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
  1592. rtp_protocol_select="udp_protocol"
  1593. sctp_protocol_deps="struct_sctp_event_subscribe"
  1594. sctp_protocol_select="network"
  1595. srtp_protocol_select="rtp_protocol"
  1596. tcp_protocol_select="network"
  1597. tls_protocol_deps_any="openssl gnutls"
  1598. tls_protocol_select="tcp_protocol"
  1599. udp_protocol_select="network"
  1600. # filters
  1601. blackframe_filter_deps="gpl"
  1602. boxblur_filter_deps="gpl"
  1603. cropdetect_filter_deps="gpl"
  1604. delogo_filter_deps="gpl"
  1605. drawtext_filter_deps="libfreetype"
  1606. frei0r_filter_deps="frei0r dlopen strtok_r"
  1607. frei0r_filter_extralibs='$ldl'
  1608. frei0r_src_filter_deps="frei0r dlopen strtok_r"
  1609. frei0r_src_filter_extralibs='$ldl'
  1610. hqdn3d_filter_deps="gpl"
  1611. resample_filter_deps="avresample"
  1612. ocv_filter_deps="libopencv"
  1613. scale_filter_deps="swscale"
  1614. yadif_filter_deps="gpl"
  1615. # libraries
  1616. avcodec_deps="avutil"
  1617. avdevice_deps="avutil avcodec avformat"
  1618. avfilter_deps="avutil"
  1619. avformat_deps="avutil avcodec"
  1620. avresample_deps="avutil"
  1621. swscale_deps="avutil"
  1622. # programs
  1623. avconv_deps="avcodec avfilter avformat avresample swscale"
  1624. avconv_select="aformat_filter anull_filter asyncts_filter format_filter
  1625. fps_filter null_filter resample_filter scale_filter
  1626. setpts_filter"
  1627. avplay_deps="avcodec avformat avresample swscale sdl"
  1628. avplay_select="rdft"
  1629. avprobe_deps="avcodec avformat"
  1630. avserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer !shared"
  1631. avserver_extralibs='$ldl'
  1632. doc_deps="texi2html"
  1633. # default parameters
  1634. logfile="config.log"
  1635. # installation paths
  1636. prefix_default="/usr/local"
  1637. bindir_default='${prefix}/bin'
  1638. datadir_default='${prefix}/share/avconv'
  1639. incdir_default='${prefix}/include'
  1640. libdir_default='${prefix}/lib'
  1641. mandir_default='${prefix}/share/man'
  1642. shlibdir_default="$libdir_default"
  1643. # toolchain
  1644. ar_default="ar"
  1645. cc_default="gcc"
  1646. host_cc_default="gcc"
  1647. cp_f="cp -f"
  1648. ln_s="ln -sf"
  1649. nm_default="nm -g"
  1650. objformat="elf"
  1651. pkg_config_default=pkg-config
  1652. ranlib="ranlib"
  1653. yasmexe="yasm"
  1654. nogas=":"
  1655. # machine
  1656. arch_default=$(uname -m)
  1657. cpu="generic"
  1658. # OS
  1659. target_os_default=$(tolower $(uname -s))
  1660. host_os=$target_os_default
  1661. # configurable options
  1662. enable $LIBRARY_LIST $PROGRAM_LIST
  1663. enable asm
  1664. enable debug
  1665. enable doc
  1666. enable optimizations
  1667. enable safe_bitstream_reader
  1668. enable static
  1669. enable swscale_alpha
  1670. # build settings
  1671. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1672. AVSERVERLDFLAGS=-Wl,-E
  1673. LIBPREF="lib"
  1674. LIBSUF=".a"
  1675. FULLNAME='$(NAME)$(BUILDSUF)'
  1676. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1677. SLIBPREF="lib"
  1678. SLIBSUF=".so"
  1679. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1680. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1681. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1682. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1683. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
  1684. SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
  1685. asflags_filter=echo
  1686. cflags_filter=echo
  1687. ldflags_filter=echo
  1688. AS_C='-c'
  1689. AS_O='-o $@'
  1690. CC_C='-c'
  1691. CC_E='-E -o $@'
  1692. CC_O='-o $@'
  1693. LD_O='-o $@'
  1694. LD_LIB='-l%'
  1695. LD_PATH='-L'
  1696. HOSTCC_C='-c'
  1697. HOSTCC_O='-o $@'
  1698. HOSTLD_O='-o $@'
  1699. host_cflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -O3 -g'
  1700. host_libs='-lm'
  1701. host_cflags_filter=echo
  1702. host_ldflags_filter=echo
  1703. target_path='$(CURDIR)'
  1704. # since the object filename is not given with the -MM flag, the compiler
  1705. # is only able to print the basename, and we must add the path ourselves
  1706. DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1707. DEPFLAGS='-MM'
  1708. # find source path
  1709. if test -f configure; then
  1710. source_path=.
  1711. else
  1712. source_path=$(cd $(dirname "$0"); pwd)
  1713. echo "$source_path" | grep -q '[[:blank:]]' &&
  1714. die "Out of tree builds are impossible with whitespace in source path."
  1715. test -e "$source_path/config.h" &&
  1716. die "Out of tree builds are impossible with config.h in source dir."
  1717. fi
  1718. for v in "$@"; do
  1719. r=${v#*=}
  1720. l=${v%"$r"}
  1721. r=$(sh_quote "$r")
  1722. LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
  1723. done
  1724. find_things(){
  1725. thing=$1
  1726. pattern=$2
  1727. file=$source_path/$3
  1728. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1729. }
  1730. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1731. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1732. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1733. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1734. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1735. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1736. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1737. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1738. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1739. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1740. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1741. ALL_COMPONENTS="
  1742. $BSF_LIST
  1743. $DECODER_LIST
  1744. $DEMUXER_LIST
  1745. $ENCODER_LIST
  1746. $FILTER_LIST
  1747. $HWACCEL_LIST
  1748. $INDEV_LIST
  1749. $MUXER_LIST
  1750. $OUTDEV_LIST
  1751. $PARSER_LIST
  1752. $PROTOCOL_LIST
  1753. "
  1754. for n in $COMPONENT_LIST; do
  1755. v=$(toupper ${n%s})_LIST
  1756. eval enable \$$v
  1757. eval ${n}_if_any="\$$v"
  1758. done
  1759. enable $ARCH_EXT_LIST
  1760. die_unknown(){
  1761. echo "Unknown option \"$1\"."
  1762. echo "See $0 --help for available options."
  1763. exit 1
  1764. }
  1765. show_list() {
  1766. suffix=_$1
  1767. shift
  1768. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
  1769. exit 0
  1770. }
  1771. rand_list(){
  1772. IFS=', '
  1773. set -- $*
  1774. unset IFS
  1775. for thing; do
  1776. comp=${thing%:*}
  1777. prob=${thing#$comp}
  1778. prob=${prob#:}
  1779. is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
  1780. echo "prob ${prob:-0.5}"
  1781. printf '%s\n' $comp
  1782. done
  1783. }
  1784. do_random(){
  1785. action=$1
  1786. shift
  1787. random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
  1788. $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
  1789. }
  1790. for opt do
  1791. optval="${opt#*=}"
  1792. case "$opt" in
  1793. --extra-ldflags=*)
  1794. add_ldflags $optval
  1795. ;;
  1796. --extra-libs=*)
  1797. add_extralibs $optval
  1798. ;;
  1799. --disable-devices)
  1800. disable $INDEV_LIST $OUTDEV_LIST
  1801. ;;
  1802. --enable-debug=*)
  1803. debuglevel="$optval"
  1804. ;;
  1805. --disable-programs)
  1806. disable $PROGRAM_LIST
  1807. ;;
  1808. --disable-everything)
  1809. map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
  1810. ;;
  1811. --disable-all)
  1812. map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
  1813. disable $LIBRARY_LIST $PROGRAM_LIST doc
  1814. ;;
  1815. --enable-random|--disable-random)
  1816. action=${opt%%-random}
  1817. do_random ${action#--} $COMPONENT_LIST
  1818. ;;
  1819. --enable-random=*|--disable-random=*)
  1820. action=${opt%%-random=*}
  1821. do_random ${action#--} $optval
  1822. ;;
  1823. --enable-*=*|--disable-*=*)
  1824. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1825. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1826. eval list=\$$(toupper $thing)_LIST
  1827. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1828. $action $(filter "$name" $list)
  1829. ;;
  1830. --enable-?*|--disable-?*)
  1831. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1832. if is_in $option $COMPONENT_LIST; then
  1833. test $action = disable && action=unset
  1834. eval $action \$$(toupper ${option%s})_LIST
  1835. elif is_in $option $CMDLINE_SELECT; then
  1836. $action $option
  1837. else
  1838. die_unknown $opt
  1839. fi
  1840. ;;
  1841. --list-*)
  1842. NAME="${opt#--list-}"
  1843. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1844. NAME=${NAME%s}
  1845. eval show_list $NAME \$$(toupper $NAME)_LIST
  1846. ;;
  1847. --help|-h) show_help
  1848. ;;
  1849. *)
  1850. optname="${opt%%=*}"
  1851. optname="${optname#--}"
  1852. optname=$(echo "$optname" | sed 's/-/_/g')
  1853. if is_in $optname $CMDLINE_SET; then
  1854. eval $optname='$optval'
  1855. elif is_in $optname $CMDLINE_APPEND; then
  1856. append $optname "$optval"
  1857. else
  1858. die_unknown $opt
  1859. fi
  1860. ;;
  1861. esac
  1862. done
  1863. disabled logging && logfile=/dev/null
  1864. echo "# $0 $LIBAV_CONFIGURATION" > $logfile
  1865. set >> $logfile
  1866. test -n "$cross_prefix" && enable cross_compile
  1867. if enabled cross_compile; then
  1868. test -n "$arch" && test -n "$target_os" ||
  1869. die "Must specify target arch and OS when cross-compiling"
  1870. fi
  1871. ar_default="${cross_prefix}${ar_default}"
  1872. cc_default="${cross_prefix}${cc_default}"
  1873. nm_default="${cross_prefix}${nm_default}"
  1874. pkg_config_default="${cross_prefix}${pkg_config_default}"
  1875. ranlib="${cross_prefix}${ranlib}"
  1876. sysinclude_default="${sysroot}/usr/include"
  1877. case "$toolchain" in
  1878. clang-asan)
  1879. cc_default="clang"
  1880. add_cflags -faddress-sanitizer
  1881. add_ldflags -faddress-sanitizer
  1882. ;;
  1883. clang-tsan)
  1884. cc_default="clang"
  1885. add_cflags -fthread-sanitizer
  1886. add_ldflags -fthread-sanitizer
  1887. ;;
  1888. msvc)
  1889. cc_default="c99wrap cl"
  1890. ld_default="c99wrap link"
  1891. nm_default="dumpbin -symbols"
  1892. ar_default="lib"
  1893. target_os_default="win32"
  1894. ;;
  1895. ?*)
  1896. die "Unknown toolchain $toolchain"
  1897. ;;
  1898. esac
  1899. set_default arch cc pkg_config sysinclude target_os
  1900. enabled cross_compile || host_cc_default=$cc
  1901. set_default host_cc
  1902. if ! $pkg_config --version >/dev/null 2>&1; then
  1903. warn "$pkg_config not found, library detection may fail."
  1904. pkg_config=false
  1905. fi
  1906. exesuf() {
  1907. case $1 in
  1908. mingw32*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
  1909. esac
  1910. }
  1911. EXESUF=$(exesuf $target_os)
  1912. HOSTEXESUF=$(exesuf $host_os)
  1913. # set temporary file name
  1914. : ${TMPDIR:=$TEMPDIR}
  1915. : ${TMPDIR:=$TMP}
  1916. : ${TMPDIR:=/tmp}
  1917. if ! check_cmd mktemp -u XXXXXX; then
  1918. # simple replacement for missing mktemp
  1919. # NOT SAFE FOR GENERAL USE
  1920. mktemp(){
  1921. echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
  1922. }
  1923. fi
  1924. tmpfile(){
  1925. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1926. (set -C; exec > $tmp) 2>/dev/null ||
  1927. die "Unable to create temporary file in $TMPDIR."
  1928. append TMPFILES $tmp
  1929. eval $1=$tmp
  1930. }
  1931. trap 'rm -f -- $TMPFILES' EXIT
  1932. tmpfile TMPASM .asm
  1933. tmpfile TMPC .c
  1934. tmpfile TMPE $EXESUF
  1935. tmpfile TMPH .h
  1936. tmpfile TMPO .o
  1937. tmpfile TMPS .S
  1938. tmpfile TMPSH .sh
  1939. tmpfile TMPV .ver
  1940. unset -f mktemp
  1941. chmod +x $TMPE
  1942. # make sure we can execute files in $TMPDIR
  1943. cat > $TMPSH 2>> $logfile <<EOF
  1944. #! /bin/sh
  1945. EOF
  1946. chmod +x $TMPSH >> $logfile 2>&1
  1947. if ! $TMPSH >> $logfile 2>&1; then
  1948. cat <<EOF
  1949. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1950. variable to another directory and make sure that it is not mounted noexec.
  1951. EOF
  1952. die "Sanity test failed."
  1953. fi
  1954. ccc_flags(){
  1955. for flag; do
  1956. case $flag in
  1957. -std=c99) echo -c99 ;;
  1958. -mcpu=*) echo -arch ${flag#*=} ;;
  1959. -mieee) echo -ieee ;;
  1960. -O*|-fast) echo $flag ;;
  1961. -fno-math-errno) echo -assume nomath_errno ;;
  1962. -g) echo -g3 ;;
  1963. -Wall) echo -msg_enable level2 ;;
  1964. -Wno-pointer-sign) echo -msg_disable ptrmismatch1 ;;
  1965. -Wl,*) echo $flag ;;
  1966. -f*|-W*) ;;
  1967. *) echo $flag ;;
  1968. esac
  1969. done
  1970. }
  1971. msvc_flags(){
  1972. for flag; do
  1973. case $flag in
  1974. -fomit-frame-pointer) echo -Oy ;;
  1975. -g) echo -Z7 ;;
  1976. -Wall) echo -W4 -wd4244 -wd4127 -wd4018 -wd4389 \
  1977. -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
  1978. -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
  1979. -wd4996 -wd4273 ;;
  1980. -std=c99) ;;
  1981. -fno-math-errno) ;;
  1982. -fno-common) ;;
  1983. -fno-signed-zeros) ;;
  1984. -fPIC) ;;
  1985. -lz) echo zlib.lib ;;
  1986. -lavifil32) echo vfw32.lib ;;
  1987. -lavicap32) echo vfw32.lib user32.lib ;;
  1988. -l*) echo ${flag#-l}.lib ;;
  1989. *) echo $flag ;;
  1990. esac
  1991. done
  1992. }
  1993. pgi_flags(){
  1994. for flag; do
  1995. case $flag in
  1996. -flto) echo -Mipa=fast,libopt,libinline,vestigial ;;
  1997. -fomit-frame-pointer) echo -Mnoframe ;;
  1998. -g) echo -gopt ;;
  1999. *) echo $flag ;;
  2000. esac
  2001. done
  2002. }
  2003. suncc_flags(){
  2004. for flag; do
  2005. case $flag in
  2006. -march=*|-mcpu=*)
  2007. case "${flag#*=}" in
  2008. native) echo -xtarget=native ;;
  2009. v9|niagara) echo -xarch=sparc ;;
  2010. ultrasparc) echo -xarch=sparcvis ;;
  2011. ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
  2012. i586|pentium) echo -xchip=pentium ;;
  2013. i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
  2014. pentium3*|c3-2) echo -xtarget=pentium3 ;;
  2015. pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
  2016. pentium4*) echo -xtarget=pentium4 ;;
  2017. prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
  2018. *-sse3) echo -xarch=sse3 ;;
  2019. core2) echo -xarch=ssse3 -xchip=core2 ;;
  2020. corei7) echo -xarch=sse4_2 -xchip=nehalem ;;
  2021. corei7-avx) echo -xarch=avx -xchip=sandybridge ;;
  2022. amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;;
  2023. athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
  2024. k8|opteron|athlon64|athlon-fx)
  2025. echo -xarch=sse2a ;;
  2026. athlon*) echo -xarch=pentium_proa ;;
  2027. esac
  2028. ;;
  2029. -std=c99) echo -xc99 ;;
  2030. -fomit-frame-pointer) echo -xregs=frameptr ;;
  2031. -fPIC) echo -KPIC -xcode=pic32 ;;
  2032. -W*,*) echo $flag ;;
  2033. -f*-*|-W*|-mimpure-text) ;;
  2034. -shared) echo -G ;;
  2035. *) echo $flag ;;
  2036. esac
  2037. done
  2038. }
  2039. tms470_flags(){
  2040. for flag; do
  2041. case $flag in
  2042. -march=*|-mcpu=*)
  2043. case "${flag#*=}" in
  2044. armv7-a|cortex-a*) echo -mv=7a8 ;;
  2045. armv7-r|cortex-r*) echo -mv=7r4 ;;
  2046. armv7-m|cortex-m*) echo -mv=7m3 ;;
  2047. armv6*|arm11*) echo -mv=6 ;;
  2048. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  2049. echo -mv=5e ;;
  2050. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  2051. esac
  2052. ;;
  2053. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  2054. -mfpu=vfp) echo --float_support=vfpv2 ;;
  2055. -mfpu=vfpv3) echo --float_support=vfpv3 ;;
  2056. -mfpu=vfpv3-d16) echo --float_support=vfpv3d16 ;;
  2057. -msoft-float) echo --float_support=vfplib ;;
  2058. -O[0-3]|-mf=*) echo $flag ;;
  2059. -g) echo -g -mn ;;
  2060. -pds=*) echo $flag ;;
  2061. -D*|-I*) echo $flag ;;
  2062. --gcc|--abi=*) echo $flag ;;
  2063. -me) echo $flag ;;
  2064. esac
  2065. done
  2066. }
  2067. probe_cc(){
  2068. pfx=$1
  2069. _cc=$2
  2070. unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
  2071. unset _ld_o _ldflags _ld_lib _ld_path
  2072. unset _depflags _DEPCMD _DEPFLAGS
  2073. _flags_filter=echo
  2074. if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
  2075. _type=llvm_gcc
  2076. gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
  2077. _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
  2078. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2079. _cflags_speed='-O3'
  2080. _cflags_size='-Os'
  2081. elif $_cc -v 2>&1 | grep -qi ^gcc; then
  2082. _type=gcc
  2083. gcc_version=$($_cc --version | head -n1)
  2084. gcc_basever=$($_cc -dumpversion)
  2085. gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
  2086. gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
  2087. _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
  2088. if ! $_cc -dumpversion | grep -q '^2\.'; then
  2089. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2090. fi
  2091. _cflags_speed='-O3'
  2092. _cflags_size='-Os'
  2093. elif $_cc --version 2>/dev/null | grep -q Intel; then
  2094. _type=icc
  2095. _ident=$($_cc --version | head -n1)
  2096. _depflags='-MMD'
  2097. _cflags_speed='-O3'
  2098. _cflags_size='-Os'
  2099. _cflags_noopt='-O1'
  2100. elif $_cc -v 2>&1 | grep -q xlc; then
  2101. _type=xlc
  2102. _ident=$($_cc -qversion 2>/dev/null | head -n1)
  2103. _cflags_speed='-O5'
  2104. _cflags_size='-O5 -qcompact'
  2105. elif $_cc -V 2>/dev/null | grep -q Compaq; then
  2106. _type=ccc
  2107. _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
  2108. _DEPFLAGS='-M'
  2109. _cflags_speed='-fast'
  2110. _cflags_size='-O1'
  2111. _flags_filter=ccc_flags
  2112. elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  2113. test -d "$sysroot" || die "No valid sysroot specified."
  2114. _type=armcc
  2115. _ident=$($_cc --vsn | head -n1)
  2116. armcc_conf="$PWD/armcc.conf"
  2117. $_cc --arm_linux_configure \
  2118. --arm_linux_config_file="$armcc_conf" \
  2119. --configure_sysroot="$sysroot" \
  2120. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  2121. die "Error creating armcc configuration file."
  2122. $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
  2123. _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
  2124. as_default="${cross_prefix}gcc"
  2125. _depflags='-MMD'
  2126. _cflags_speed='-O3'
  2127. _cflags_size='-Os'
  2128. elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
  2129. _type=tms470
  2130. _ident=$($_cc -version | head -n1 | tr -s ' ')
  2131. _flags='--gcc --abi=eabi -me'
  2132. _cc_e='-ppl -fe=$@'
  2133. _cc_o='-fe=$@'
  2134. _depflags='-ppa -ppd=$(@:.o=.d)'
  2135. _cflags_speed='-O3 -mf=5'
  2136. _cflags_size='-O3 -mf=2'
  2137. _flags_filter=tms470_flags
  2138. elif $_cc -v 2>&1 | grep -q clang; then
  2139. _type=clang
  2140. _ident=$($_cc --version | head -n1)
  2141. _depflags='-MMD'
  2142. _cflags_speed='-O3'
  2143. _cflags_size='-Os'
  2144. elif $_cc -V 2>&1 | grep -q Sun; then
  2145. _type=suncc
  2146. _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
  2147. _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
  2148. _DEPFLAGS='-xM1 -xc99'
  2149. _ldflags='-std=c99'
  2150. _cflags_speed='-O5'
  2151. _cflags_size='-O5 -xspace'
  2152. _flags_filter=suncc_flags
  2153. elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
  2154. _type=pathscale
  2155. _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
  2156. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2157. _cflags_speed='-O2'
  2158. _cflags_size='-Os'
  2159. _flags_filter='filter_out -Wdisabled-optimization'
  2160. elif $_cc -v 2>&1 | grep -q Open64; then
  2161. _type=open64
  2162. _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
  2163. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2164. _cflags_speed='-O2'
  2165. _cflags_size='-Os'
  2166. _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
  2167. elif $_cc -V 2>&1 | grep -q Portland; then
  2168. _type=pgi
  2169. _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
  2170. opt_common='-alias=ansi -Mdse -Mlre -Mpre'
  2171. _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
  2172. _cflags_size="-O2 -Munroll=c:1 $opt_common"
  2173. _cflags_noopt="-O1"
  2174. _flags_filter=pgi_flags
  2175. elif $_cc 2>&1 | grep -q Microsoft; then
  2176. _type=msvc
  2177. _ident=$($cc 2>&1 | head -n1)
  2178. _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
  2179. _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
  2180. _cflags_speed="-O2"
  2181. _cflags_size="-O1"
  2182. # Nonstandard output options, to avoid msys path conversion issues, relies on wrapper to remap it
  2183. if $_cc 2>&1 | grep -q Linker; then
  2184. _ld_o='-out $@'
  2185. else
  2186. _ld_o='-Fe$@'
  2187. fi
  2188. _cc_o='-Fo $@'
  2189. _cc_e='-P -Fi $@'
  2190. _flags_filter=msvc_flags
  2191. _ld_lib='lib%.a'
  2192. _ld_path='-libpath:'
  2193. _flags='-nologo'
  2194. _cflags='-D_USE_MATH_DEFINES -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64'
  2195. if [ $pfx = hostcc ]; then
  2196. append _cflags -Dsnprintf=_snprintf
  2197. fi
  2198. fi
  2199. eval ${pfx}_type=\$_type
  2200. eval ${pfx}_ident=\$_ident
  2201. }
  2202. set_ccvars(){
  2203. eval ${1}_C=\${_cc_c-\${${1}_C}}
  2204. eval ${1}_E=\${_cc_e-\${${1}_E}}
  2205. eval ${1}_O=\${_cc_o-\${${1}_O}}
  2206. if [ -n "$_depflags" ]; then
  2207. eval ${1}_DEPFLAGS=\$_depflags
  2208. else
  2209. eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
  2210. eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
  2211. eval DEP${1}FLAGS=\$_flags
  2212. fi
  2213. }
  2214. probe_cc cc "$cc"
  2215. cflags_filter=$_flags_filter
  2216. cflags_speed=$_cflags_speed
  2217. cflags_size=$_cflags_size
  2218. cflags_noopt=$_cflags_noopt
  2219. add_cflags $_flags $_cflags
  2220. cc_ldflags=$_ldflags
  2221. set_ccvars CC
  2222. probe_cc hostcc "$host_cc"
  2223. host_cflags_filter=$_flags_filter
  2224. add_host_cflags $_flags $_cflags
  2225. set_ccvars HOSTCC
  2226. test -n "$cc_type" && enable $cc_type ||
  2227. warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
  2228. : ${as_default:=$cc}
  2229. : ${dep_cc_default:=$cc}
  2230. : ${ld_default:=$cc}
  2231. : ${host_ld_default:=$host_cc}
  2232. set_default ar as dep_cc ld host_ld
  2233. probe_cc as "$as"
  2234. asflags_filter=$_flags_filter
  2235. add_asflags $_flags $_cflags
  2236. set_ccvars AS
  2237. probe_cc ld "$ld"
  2238. ldflags_filter=$_flags_filter
  2239. add_ldflags $_flags $_ldflags
  2240. test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
  2241. LD_O=${_ld_o-$LD_O}
  2242. LD_LIB=${_ld_lib-$LD_LIB}
  2243. LD_PATH=${_ld_path-$LD_PATH}
  2244. probe_cc hostld "$host_ld"
  2245. host_ldflags_filter=$_flags_filter
  2246. add_host_ldflags $_flags $_ldflags
  2247. HOSTLD_O=${_ld_o-$HOSTLD_O}
  2248. if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
  2249. probe_cc depcc "$dep_cc"
  2250. CCDEP=${_DEPCMD:-$DEPCMD}
  2251. CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
  2252. DEPCCFLAGS=$_flags
  2253. fi
  2254. if $ar 2>&1 | grep -q Microsoft; then
  2255. arflags="-nologo"
  2256. ar_o='-out:$@'
  2257. elif $ar 2>&1 | grep -q 'Texas Instruments'; then
  2258. arflags="rq"
  2259. ar_o='$@'
  2260. else
  2261. arflags="rc"
  2262. ar_o='$@'
  2263. fi
  2264. add_cflags $extra_cflags
  2265. add_asflags $extra_cflags
  2266. if test -n "$sysroot"; then
  2267. case "$cc_type" in
  2268. gcc|llvm_gcc|clang)
  2269. add_cppflags --sysroot="$sysroot"
  2270. add_ldflags --sysroot="$sysroot"
  2271. ;;
  2272. tms470)
  2273. add_cppflags -I"$sysinclude"
  2274. add_ldflags --sysroot="$sysroot"
  2275. ;;
  2276. esac
  2277. fi
  2278. if test "$cpu" = host; then
  2279. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  2280. case "$cc_type" in
  2281. gcc|llvm_gcc)
  2282. check_native(){
  2283. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  2284. sed -n "/cc1.*$1=/{
  2285. s/.*$1=\\([^ ]*\\).*/\\1/
  2286. p
  2287. q
  2288. }" $TMPE
  2289. }
  2290. cpu=$(check_native -march || check_native -mcpu)
  2291. ;;
  2292. esac
  2293. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  2294. fi
  2295. # Deal with common $arch aliases
  2296. case "$arch" in
  2297. aarch64|arm64)
  2298. arch="aarch64"
  2299. ;;
  2300. arm*)
  2301. arch="arm"
  2302. ;;
  2303. mips*|IP*)
  2304. arch="mips"
  2305. ;;
  2306. parisc*|hppa*)
  2307. arch="parisc"
  2308. ;;
  2309. "Power Macintosh"|ppc*|powerpc*)
  2310. arch="ppc"
  2311. ;;
  2312. s390|s390x)
  2313. arch="s390"
  2314. ;;
  2315. sh4|sh)
  2316. arch="sh4"
  2317. ;;
  2318. sun4u|sparc*)
  2319. arch="sparc"
  2320. ;;
  2321. tilegx|tile-gx)
  2322. arch="tilegx"
  2323. ;;
  2324. i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
  2325. arch="x86"
  2326. ;;
  2327. esac
  2328. is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
  2329. enable $arch
  2330. # Add processor-specific flags
  2331. if enabled aarch64; then
  2332. case $cpu in
  2333. armv*)
  2334. cpuflags="-march=$cpu"
  2335. ;;
  2336. *)
  2337. cpuflags="-mcpu=$cpu"
  2338. ;;
  2339. esac
  2340. elif enabled alpha; then
  2341. cpuflags="-mcpu=$cpu"
  2342. elif enabled arm; then
  2343. check_arm_arch() {
  2344. check_cpp_condition stddef.h \
  2345. "defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
  2346. $cpuflags
  2347. }
  2348. probe_arm_arch() {
  2349. if check_arm_arch 4; then echo armv4;
  2350. elif check_arm_arch 4T; then echo armv4t;
  2351. elif check_arm_arch 5; then echo armv5;
  2352. elif check_arm_arch 5E; then echo armv5e;
  2353. elif check_arm_arch 5T; then echo armv5t;
  2354. elif check_arm_arch 5TE; then echo armv5te;
  2355. elif check_arm_arch 5TEJ; then echo armv5te;
  2356. elif check_arm_arch 6; then echo armv6;
  2357. elif check_arm_arch 6J; then echo armv6j;
  2358. elif check_arm_arch 6K; then echo armv6k;
  2359. elif check_arm_arch 6Z; then echo armv6z;
  2360. elif check_arm_arch 6ZK; then echo armv6zk;
  2361. elif check_arm_arch 6T2; then echo armv6t2;
  2362. elif check_arm_arch 7; then echo armv7;
  2363. elif check_arm_arch 7A 7_A; then echo armv7-a;
  2364. elif check_arm_arch 7R 7_R; then echo armv7-r;
  2365. elif check_arm_arch 7M 7_M; then echo armv7-m;
  2366. elif check_arm_arch 7EM 7E_M; then echo armv7-m;
  2367. elif check_arm_arch 8A 8_A; then echo armv8-a;
  2368. fi
  2369. }
  2370. [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
  2371. case $cpu in
  2372. armv*)
  2373. cpuflags="-march=$cpu"
  2374. subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
  2375. ;;
  2376. *)
  2377. cpuflags="-mcpu=$cpu"
  2378. case $cpu in
  2379. cortex-a*) subarch=armv7a ;;
  2380. cortex-r*) subarch=armv7r ;;
  2381. cortex-m*) enable thumb; subarch=armv7m ;;
  2382. arm11*) subarch=armv6 ;;
  2383. arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
  2384. armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
  2385. *) subarch=$(probe_arm_arch) ;;
  2386. esac
  2387. ;;
  2388. esac
  2389. case "$subarch" in
  2390. armv5t*) enable fast_clz ;;
  2391. armv[6-8]*) enable fast_clz fast_unaligned ;;
  2392. esac
  2393. elif enabled avr32; then
  2394. case $cpu in
  2395. ap7[02]0[0-2])
  2396. subarch="avr32_ap"
  2397. cpuflags="-mpart=$cpu"
  2398. ;;
  2399. ap)
  2400. subarch="avr32_ap"
  2401. cpuflags="-march=$cpu"
  2402. ;;
  2403. uc3[ab]*)
  2404. subarch="avr32_uc"
  2405. cpuflags="-mcpu=$cpu"
  2406. ;;
  2407. uc)
  2408. subarch="avr32_uc"
  2409. cpuflags="-march=$cpu"
  2410. ;;
  2411. esac
  2412. elif enabled bfin; then
  2413. cpuflags="-mcpu=$cpu"
  2414. elif enabled mips; then
  2415. cpuflags="-march=$cpu"
  2416. elif enabled ppc; then
  2417. case $(tolower $cpu) in
  2418. 601|ppc601|powerpc601)
  2419. cpuflags="-mcpu=601"
  2420. disable altivec
  2421. ;;
  2422. 603*|ppc603*|powerpc603*)
  2423. cpuflags="-mcpu=603"
  2424. disable altivec
  2425. ;;
  2426. 604*|ppc604*|powerpc604*)
  2427. cpuflags="-mcpu=604"
  2428. disable altivec
  2429. ;;
  2430. g3|75*|ppc75*|powerpc75*)
  2431. cpuflags="-mcpu=750"
  2432. disable altivec
  2433. ;;
  2434. g4|745*|ppc745*|powerpc745*)
  2435. cpuflags="-mcpu=7450"
  2436. ;;
  2437. 74*|ppc74*|powerpc74*)
  2438. cpuflags="-mcpu=7400"
  2439. ;;
  2440. g5|970|ppc970|powerpc970)
  2441. cpuflags="-mcpu=970"
  2442. ;;
  2443. power[3-7]*)
  2444. cpuflags="-mcpu=$cpu"
  2445. ;;
  2446. cell)
  2447. cpuflags="-mcpu=cell"
  2448. enable ldbrx
  2449. ;;
  2450. e500mc)
  2451. cpuflags="-mcpu=e500mc"
  2452. disable altivec
  2453. ;;
  2454. e500v2)
  2455. cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
  2456. disable altivec
  2457. ;;
  2458. e500)
  2459. cpuflags="-mcpu=8540 -mhard-float"
  2460. disable altivec
  2461. ;;
  2462. esac
  2463. elif enabled sparc; then
  2464. case $cpu in
  2465. cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
  2466. cpuflags="-mcpu=$cpu"
  2467. disable vis
  2468. ;;
  2469. ultrasparc*|niagara[234])
  2470. cpuflags="-mcpu=$cpu"
  2471. ;;
  2472. esac
  2473. elif enabled x86; then
  2474. case $cpu in
  2475. i[345]86|pentium)
  2476. cpuflags="-march=$cpu"
  2477. disable mmx
  2478. ;;
  2479. # targets that do NOT support conditional mov (cmov)
  2480. pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  2481. cpuflags="-march=$cpu"
  2482. disable cmov
  2483. ;;
  2484. # targets that do support conditional mov (cmov)
  2485. 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*)
  2486. cpuflags="-march=$cpu"
  2487. enable cmov
  2488. enable fast_cmov
  2489. ;;
  2490. # targets that do support conditional mov but on which it's slow
  2491. pentium4|pentium4m|prescott|nocona)
  2492. cpuflags="-march=$cpu"
  2493. enable cmov
  2494. disable fast_cmov
  2495. ;;
  2496. esac
  2497. fi
  2498. if [ "$cpu" != generic ]; then
  2499. add_cflags $cpuflags
  2500. add_asflags $cpuflags
  2501. fi
  2502. # compiler sanity check
  2503. check_exec <<EOF
  2504. int main(void){ return 0; }
  2505. EOF
  2506. if test "$?" != 0; then
  2507. echo "$cc is unable to create an executable file."
  2508. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  2509. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  2510. echo "Only do this if you know what cross compiling means."
  2511. fi
  2512. die "C compiler test failed."
  2513. fi
  2514. add_cppflags -D_ISOC99_SOURCE
  2515. check_cflags -std=c99
  2516. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  2517. #include <stdlib.h>
  2518. EOF
  2519. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  2520. #include <stdlib.h>
  2521. EOF
  2522. check_host_cflags -std=c99
  2523. check_host_cflags -Wall
  2524. check_64bit(){
  2525. arch32=$1
  2526. arch64=$2
  2527. expr=$3
  2528. check_code cc "" "int test[2*($expr) - 1]" &&
  2529. subarch=$arch64 || subarch=$arch32
  2530. }
  2531. case "$arch" in
  2532. aarch64|alpha|ia64)
  2533. spic=$shared
  2534. ;;
  2535. mips)
  2536. check_64bit mips mips64 '_MIPS_SIM > 1'
  2537. spic=$shared
  2538. ;;
  2539. parisc)
  2540. check_64bit parisc parisc64 'sizeof(void *) > 4'
  2541. spic=$shared
  2542. ;;
  2543. ppc)
  2544. check_64bit ppc ppc64 'sizeof(void *) > 4'
  2545. spic=$shared
  2546. ;;
  2547. sparc)
  2548. check_64bit sparc sparc64 'sizeof(void *) > 4'
  2549. spic=$shared
  2550. ;;
  2551. x86)
  2552. check_64bit x86_32 x86_64 'sizeof(void *) > 4'
  2553. if test "$subarch" = "x86_64"; then
  2554. spic=$shared
  2555. fi
  2556. ;;
  2557. esac
  2558. enable $subarch
  2559. enabled spic && enable pic
  2560. # OS specific
  2561. case $target_os in
  2562. haiku)
  2563. prefix_default="/boot/common"
  2564. network_extralibs="-lnetwork"
  2565. host_libs=
  2566. ;;
  2567. sunos)
  2568. AVSERVERLDFLAGS=""
  2569. SHFLAGS='-shared -Wl,-h,$$(@F)'
  2570. enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
  2571. network_extralibs="-lsocket -lnsl"
  2572. add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
  2573. # When using suncc to build, the Solaris linker will mark
  2574. # an executable with each instruction set encountered by
  2575. # the Solaris assembler. As our libraries contain their own
  2576. # guards for processor-specific code, instead suppress
  2577. # generation of the HWCAPS ELF section on Solaris x86 only.
  2578. enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
  2579. nm_default='nm -P -g'
  2580. ;;
  2581. netbsd)
  2582. disable symver
  2583. oss_indev_extralibs="-lossaudio"
  2584. oss_outdev_extralibs="-lossaudio"
  2585. ;;
  2586. openbsd|bitrig)
  2587. disable symver
  2588. SHFLAGS='-shared'
  2589. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBVERSION)'
  2590. SLIB_INSTALL_LINKS=
  2591. oss_indev_extralibs="-lossaudio"
  2592. oss_outdev_extralibs="-lossaudio"
  2593. ;;
  2594. dragonfly)
  2595. disable symver
  2596. ;;
  2597. freebsd)
  2598. ;;
  2599. bsd/os)
  2600. add_extralibs -lpoll -lgnugetopt
  2601. ;;
  2602. darwin)
  2603. gas="gas-preprocessor.pl $cc"
  2604. enabled ppc && add_asflags -force_cpusubtype_ALL
  2605. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
  2606. enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
  2607. add_ldflags -Wl,-dynamic,-search_paths_first
  2608. SLIBSUF=".dylib"
  2609. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  2610. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  2611. AVSERVERLDFLAGS=-Wl,-bind_at_load
  2612. objformat="macho"
  2613. enabled x86_64 && objformat="macho64"
  2614. enabled_any pic shared ||
  2615. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  2616. ;;
  2617. mingw32*)
  2618. if test $target_os = "mingw32ce"; then
  2619. disable network
  2620. else
  2621. target_os=mingw32
  2622. fi
  2623. LIBTARGET=i386
  2624. if enabled x86_64; then
  2625. LIBTARGET="i386:x86-64"
  2626. elif enabled arm; then
  2627. LIBTARGET=arm-wince
  2628. fi
  2629. shlibdir_default="$bindir_default"
  2630. SLIBPREF=""
  2631. SLIBSUF=".dll"
  2632. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2633. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2634. 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)'
  2635. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2636. SLIB_INSTALL_LINKS=
  2637. SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
  2638. SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
  2639. 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'
  2640. objformat="win32"
  2641. dlltool="${cross_prefix}dlltool"
  2642. ranlib=:
  2643. enable dos_paths
  2644. add_cppflags -U__STRICT_ANSI__
  2645. ;;
  2646. win32|win64)
  2647. if enabled shared; then
  2648. # Link to the import library instead of the normal static library
  2649. # for shared libs.
  2650. LD_LIB='%.lib'
  2651. # Cannot build shared and static libraries at the same time with
  2652. # MSVC.
  2653. disable static
  2654. fi
  2655. shlibdir_default="$bindir_default"
  2656. SLIBPREF=""
  2657. SLIBSUF=".dll"
  2658. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2659. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2660. SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
  2661. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2662. SLIB_INSTALL_LINKS=
  2663. SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
  2664. SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
  2665. SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
  2666. objformat="win32"
  2667. ranlib=:
  2668. enable dos_paths
  2669. ;;
  2670. cygwin*)
  2671. target_os=cygwin
  2672. shlibdir_default="$bindir_default"
  2673. SLIBPREF="cyg"
  2674. SLIBSUF=".dll"
  2675. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2676. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2677. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2678. SLIB_INSTALL_LINKS=
  2679. SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
  2680. SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
  2681. objformat="win32"
  2682. enable dos_paths
  2683. ;;
  2684. *-dos|freedos|opendos)
  2685. network_extralibs="-lsocket"
  2686. objformat="coff"
  2687. enable dos_paths
  2688. add_cppflags -U__STRICT_ANSI__
  2689. ;;
  2690. linux)
  2691. enable dv1394
  2692. ;;
  2693. irix*)
  2694. target_os=irix
  2695. ranlib="echo ignoring ranlib"
  2696. ;;
  2697. os/2*)
  2698. ln_s="cp -f"
  2699. objformat="aout"
  2700. add_cppflags -D_GNU_SOURCE
  2701. add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
  2702. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  2703. AVSERVERLDFLAGS=""
  2704. LIBSUF="_s.a"
  2705. SLIBPREF=""
  2706. SLIBSUF=".dll"
  2707. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  2708. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  2709. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  2710. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  2711. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  2712. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  2713. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  2714. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  2715. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  2716. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  2717. SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
  2718. enable dos_paths
  2719. ;;
  2720. gnu/kfreebsd)
  2721. add_cppflags -D_BSD_SOURCE
  2722. ;;
  2723. gnu)
  2724. ;;
  2725. qnx)
  2726. add_cppflags -D_QNX_SOURCE
  2727. network_extralibs="-lsocket"
  2728. ;;
  2729. symbian)
  2730. SLIBSUF=".dll"
  2731. enable dos_paths
  2732. add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
  2733. add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
  2734. add_ldflags -Wl,--target1-abs,--no-undefined \
  2735. -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
  2736. -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
  2737. add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
  2738. -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
  2739. -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
  2740. ;;
  2741. osf1)
  2742. add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
  2743. AVSERVERLDFLAGS=
  2744. ;;
  2745. minix)
  2746. ;;
  2747. plan9)
  2748. add_cppflags -D_C99_SNPRINTF_EXTENSION \
  2749. -D_REENTRANT_SOURCE \
  2750. -D_RESEARCH_SOURCE \
  2751. -DFD_SETSIZE=96 \
  2752. -DHAVE_SOCK_OPTS
  2753. add_compat strtod.o strtod=avpriv_strtod
  2754. network_extralibs='-lbsd'
  2755. exeobjs=compat/plan9/main.o
  2756. disable avserver
  2757. ln_s='ln -s -f'
  2758. cp_f='cp'
  2759. ;;
  2760. none)
  2761. ;;
  2762. *)
  2763. die "Unknown OS '$target_os'."
  2764. ;;
  2765. esac
  2766. # determine libc flavour
  2767. if check_cpp_condition features.h "defined __UCLIBC__"; then
  2768. libc_type=uclibc
  2769. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2770. elif check_cpp_condition features.h "defined __GLIBC__"; then
  2771. libc_type=glibc
  2772. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2773. elif check_header _mingw.h; then
  2774. libc_type=mingw
  2775. check_cpp_condition _mingw.h \
  2776. "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || \
  2777. (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  2778. die "ERROR: MinGW runtime version must be >= 3.15."
  2779. elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
  2780. libc_type=newlib
  2781. add_cppflags -U__STRICT_ANSI__
  2782. elif check_func_headers stdlib.h _get_doserrno; then
  2783. libc_type=msvcrt
  2784. add_compat strtod.o strtod=avpriv_strtod
  2785. add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf \
  2786. _snprintf=avpriv_snprintf \
  2787. vsnprintf=avpriv_vsnprintf
  2788. elif check_cpp_condition stddef.h "defined __KLIBC__"; then
  2789. libc_type=klibc
  2790. fi
  2791. test -n "$libc_type" && enable $libc_type
  2792. # hacks for compiler/libc/os combinations
  2793. if enabled_all tms470 glibc; then
  2794. CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
  2795. add_cppflags -D__USER_LABEL_PREFIX__=
  2796. add_cppflags -D__builtin_memset=memset
  2797. add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
  2798. add_cflags -pds=48 # incompatible redefinition of macro
  2799. fi
  2800. if enabled_all ccc glibc; then
  2801. add_ldflags -Wl,-z,now # calls to libots crash without this
  2802. fi
  2803. esc(){
  2804. echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
  2805. }
  2806. echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" >config.fate
  2807. check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
  2808. set_default $PATHS_LIST
  2809. set_default nm
  2810. # we need to build at least one lib type
  2811. if ! enabled_any static shared; then
  2812. cat <<EOF
  2813. At least one library type must be built.
  2814. Specify --enable-static to build the static libraries or --enable-shared to
  2815. build the shared libraries as well. To only build the shared libraries specify
  2816. --disable-static in addition to --enable-shared.
  2817. EOF
  2818. exit 1;
  2819. fi
  2820. die_license_disabled() {
  2821. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  2822. }
  2823. die_license_disabled gpl libcdio
  2824. die_license_disabled gpl libx264
  2825. die_license_disabled gpl libxavs
  2826. die_license_disabled gpl libxvid
  2827. die_license_disabled gpl x11grab
  2828. die_license_disabled nonfree libfaac
  2829. die_license_disabled nonfree libfdk_aac
  2830. die_license_disabled nonfree openssl
  2831. die_license_disabled version3 libopencore_amrnb
  2832. die_license_disabled version3 libopencore_amrwb
  2833. die_license_disabled version3 libvo_aacenc
  2834. die_license_disabled version3 libvo_amrwbenc
  2835. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  2836. disabled optimizations || check_cflags -fomit-frame-pointer
  2837. enable_pic() {
  2838. enable pic
  2839. add_cppflags -DPIC
  2840. add_cflags -fPIC
  2841. add_asflags -fPIC
  2842. }
  2843. enabled pic && enable_pic
  2844. check_cc <<EOF || die "Symbol mangling check failed."
  2845. int ff_extern;
  2846. EOF
  2847. sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
  2848. extern_prefix=${sym%%ff_extern*}
  2849. check_cc <<EOF && enable_weak inline_asm
  2850. void foo(void) { __asm__ volatile ("" ::); }
  2851. EOF
  2852. _restrict=
  2853. for restrict_keyword in restrict __restrict__ __restrict; do
  2854. check_cc <<EOF && _restrict=$restrict_keyword && break
  2855. void foo(char * $restrict_keyword p);
  2856. EOF
  2857. done
  2858. check_cc <<EOF && enable attribute_packed
  2859. struct { int x; } __attribute__((packed)) x;
  2860. EOF
  2861. check_cc <<EOF && enable attribute_may_alias
  2862. union { int x; } __attribute__((may_alias)) x;
  2863. EOF
  2864. check_cc <<EOF || die "endian test failed"
  2865. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  2866. EOF
  2867. od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  2868. if enabled alpha; then
  2869. check_cflags -mieee
  2870. elif enabled arm; then
  2871. check_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
  2872. enabled thumb && check_cflags -mthumb || check_cflags -marm
  2873. nogas=die
  2874. if check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
  2875. enable vfp_args
  2876. elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
  2877. case "${cross_prefix:-$cc}" in
  2878. *hardfloat*) enable vfp_args; fpabi=vfp ;;
  2879. *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
  2880. __asm__ (".eabi_attribute 28, 1");
  2881. int main(void) { return 0; }
  2882. EOF
  2883. esac
  2884. warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
  2885. fi
  2886. enabled armv5te && check_insn armv5te 'qadd r0, r0, r0'
  2887. enabled armv6 && check_insn armv6 'sadd16 r0, r0, r0'
  2888. enabled armv6t2 && check_insn armv6t2 'movt r0, #0'
  2889. enabled neon && check_insn neon 'vadd.i16 q0, q0, q0'
  2890. enabled vfp && check_insn vfp 'fadds s0, s0, s0'
  2891. enabled vfpv3 && check_insn vfpv3 'vmov.f32 s0, #1.0'
  2892. [ $target_os = linux ] ||
  2893. map 'enabled_any ${v}_external ${v}_inline || disable $v' \
  2894. $ARCH_EXT_LIST_ARM
  2895. check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
  2896. check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
  2897. enabled_all armv6t2 shared !pic && enable_pic
  2898. elif enabled mips; then
  2899. check_inline_asm loongson '"dmult.g $1, $2, $3"'
  2900. elif enabled parisc; then
  2901. if enabled gcc; then
  2902. case $($cc -dumpversion) in
  2903. 4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
  2904. esac
  2905. fi
  2906. elif enabled ppc; then
  2907. enable local_aligned_8 local_aligned_16
  2908. check_inline_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
  2909. check_inline_asm ibm_asm '"add 0, 0, 0"'
  2910. check_inline_asm ppc4xx '"maclhw r10, r11, r12"'
  2911. check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
  2912. # AltiVec flags: The FSF version of GCC differs from the Apple version
  2913. if enabled altivec; then
  2914. nogas=warn
  2915. check_cflags -maltivec -mabi=altivec &&
  2916. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  2917. check_cflags -faltivec
  2918. # check if our compiler supports Motorola AltiVec C API
  2919. check_cc <<EOF || disable altivec
  2920. $inc_altivec_h
  2921. int main(void) {
  2922. vector signed int v1 = (vector signed int) { 0 };
  2923. vector signed int v2 = (vector signed int) { 1 };
  2924. v1 = vec_add(v1, v2);
  2925. return 0;
  2926. }
  2927. EOF
  2928. enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
  2929. fi
  2930. elif enabled sparc; then
  2931. enabled vis && check_inline_asm vis '"pdist %f0, %f0, %f0"'
  2932. elif enabled x86; then
  2933. check_code ld intrin.h "__rdtsc()" && enable rdtsc
  2934. check_code ld mmintrin.h "_mm_empty()" && enable mm_empty
  2935. enable local_aligned_8 local_aligned_16
  2936. # check whether EBP is available on x86
  2937. # As 'i' is stored on the stack, this program will crash
  2938. # if the base pointer is used to access it because the
  2939. # base pointer is cleared in the inline assembly code.
  2940. check_exec_crash <<EOF && enable ebp_available
  2941. volatile int i=0;
  2942. __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
  2943. return i;
  2944. EOF
  2945. # check whether EBX is available on x86
  2946. check_inline_asm ebx_available '""::"b"(0)' &&
  2947. check_inline_asm ebx_available '"":::"%ebx"'
  2948. # check whether xmm clobbers are supported
  2949. check_inline_asm xmm_clobbers '"":::"%xmm0"'
  2950. # check whether binutils is new enough to compile SSSE3/MMXEXT
  2951. enabled ssse3 && check_inline_asm ssse3_inline '"pabsw %xmm0, %xmm0"'
  2952. enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
  2953. if ! disabled_any asm mmx yasm; then
  2954. if check_cmd $yasmexe --version; then
  2955. enabled x86_64 && yasm_extra="-m amd64"
  2956. yasm_debug="-g dwarf2"
  2957. elif check_cmd nasm -v; then
  2958. yasmexe=nasm
  2959. yasm_debug="-g -F dwarf"
  2960. enabled x86_64 && test "$objformat" = elf && objformat=elf64
  2961. fi
  2962. YASMFLAGS="-f $objformat $yasm_extra"
  2963. enabled pic && append YASMFLAGS "-DPIC"
  2964. test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
  2965. case "$objformat" in
  2966. elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
  2967. esac
  2968. check_yasm "vextractf128 xmm0, ymm0, 0" && enable yasm ||
  2969. die "yasm not found, use --disable-yasm for a crippled build"
  2970. check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
  2971. check_yasm "CPU amdnop" && enable cpunop
  2972. fi
  2973. case "$cpu" in
  2974. athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
  2975. disable fast_clz
  2976. ;;
  2977. esac
  2978. fi
  2979. if enabled asm; then
  2980. as=${gas:=$as}
  2981. check_as <<EOF && enable gnu_as || \
  2982. $nogas "GNU assembler not found, install gas-preprocessor"
  2983. .macro m n
  2984. \n: .int 0
  2985. .endm
  2986. m x
  2987. EOF
  2988. fi
  2989. check_ldflags -Wl,--as-needed
  2990. if check_func dlopen; then
  2991. ldl=
  2992. elif check_func dlopen -ldl; then
  2993. ldl=-ldl
  2994. fi
  2995. if ! disabled network; then
  2996. check_type "sys/types.h sys/socket.h" socklen_t
  2997. check_type netdb.h "struct addrinfo"
  2998. check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
  2999. check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
  3000. check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
  3001. check_type netinet/in.h "struct sockaddr_in6"
  3002. check_type poll.h "struct pollfd"
  3003. check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
  3004. check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
  3005. check_type netinet/sctp.h "struct sctp_event_subscribe"
  3006. check_func getaddrinfo $network_extralibs
  3007. check_func getservbyport $network_extralibs
  3008. # Prefer arpa/inet.h over winsock2
  3009. if check_header arpa/inet.h ; then
  3010. check_func closesocket
  3011. elif check_header winsock2.h ; then
  3012. check_func_headers winsock2.h closesocket -lws2 &&
  3013. network_extralibs="-lws2" ||
  3014. { check_func_headers winsock2.h closesocket -lws2_32 &&
  3015. network_extralibs="-lws2_32"; }
  3016. check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
  3017. check_type ws2tcpip.h socklen_t
  3018. check_type ws2tcpip.h "struct addrinfo"
  3019. check_type ws2tcpip.h "struct group_source_req"
  3020. check_type ws2tcpip.h "struct ip_mreq_source"
  3021. check_type ws2tcpip.h "struct ipv6_mreq"
  3022. check_type winsock2.h "struct pollfd"
  3023. check_type ws2tcpip.h "struct sockaddr_in6"
  3024. check_type ws2tcpip.h "struct sockaddr_storage"
  3025. check_struct winsock2.h "struct sockaddr" sa_len
  3026. else
  3027. disable network
  3028. fi
  3029. fi
  3030. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  3031. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  3032. check_func fcntl
  3033. check_func fork
  3034. check_func gethrtime
  3035. check_func getopt
  3036. check_func getrusage
  3037. check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
  3038. check_func gettimeofday
  3039. check_func inet_aton $network_extralibs
  3040. check_func isatty
  3041. check_func localtime_r
  3042. check_func ${malloc_prefix}memalign && enable memalign
  3043. check_func mkstemp
  3044. check_func mmap
  3045. check_func mprotect
  3046. check_func ${malloc_prefix}posix_memalign && enable posix_memalign
  3047. check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
  3048. check_func setrlimit
  3049. check_func strerror_r
  3050. check_func strptime
  3051. check_func strtok_r
  3052. check_func sched_getaffinity
  3053. check_func sysconf
  3054. check_func sysctl
  3055. check_func usleep
  3056. check_func_headers io.h setmode
  3057. check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
  3058. check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
  3059. check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
  3060. check_func_headers windows.h GetProcessAffinityMask
  3061. check_func_headers windows.h GetProcessTimes
  3062. check_func_headers windows.h GetSystemTimeAsFileTime
  3063. check_func_headers windows.h MapViewOfFile
  3064. check_func_headers windows.h SetConsoleTextAttribute
  3065. check_func_headers windows.h Sleep
  3066. check_func_headers windows.h VirtualAlloc
  3067. check_header direct.h
  3068. check_header dlfcn.h
  3069. check_header dxva.h
  3070. check_header dxva2api.h
  3071. check_header io.h
  3072. check_header malloc.h
  3073. check_header poll.h
  3074. check_header sys/mman.h
  3075. check_header sys/param.h
  3076. check_header sys/resource.h
  3077. check_header sys/select.h
  3078. check_header sys/time.h
  3079. check_header unistd.h
  3080. check_header vdpau/vdpau.h
  3081. check_header vdpau/vdpau_x11.h
  3082. check_header windows.h
  3083. check_header X11/extensions/XvMClib.h
  3084. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  3085. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  3086. if ! disabled w32threads && ! enabled pthreads; then
  3087. check_func_headers "windows.h process.h" _beginthreadex && enable w32threads
  3088. fi
  3089. # check for some common methods of building with pthread support
  3090. # do this before the optional library checks as some of them require pthreads
  3091. if ! disabled pthreads && ! enabled w32threads; then
  3092. enable pthreads
  3093. if check_func pthread_create; then
  3094. :
  3095. elif check_func pthread_create -pthread; then
  3096. add_cflags -pthread
  3097. add_extralibs -pthread
  3098. elif check_func pthread_create -pthreads; then
  3099. add_cflags -pthreads
  3100. add_extralibs -pthreads
  3101. elif check_func pthread_create -lpthreadGC2; then
  3102. add_extralibs -lpthreadGC2
  3103. elif ! check_lib pthread.h pthread_create -lpthread; then
  3104. disable pthreads
  3105. fi
  3106. fi
  3107. for thread in $THREADS_LIST; do
  3108. if enabled $thread; then
  3109. test -n "$thread_type" &&
  3110. die "ERROR: Only one thread type must be selected." ||
  3111. thread_type="$thread"
  3112. fi
  3113. done
  3114. check_lib math.h sin -lm && LIBM="-lm"
  3115. enabled vaapi && require vaapi va/va.h vaInitialize -lva
  3116. atan2f_args=2
  3117. ldexpf_args=2
  3118. powf_args=2
  3119. for func in $MATH_FUNCS; do
  3120. eval check_mathfunc $func \${${func}_args:-1}
  3121. done
  3122. # these are off by default, so fail if requested and not available
  3123. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
  3124. enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
  3125. enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
  3126. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  3127. enabled libfdk_aac && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
  3128. enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
  3129. enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
  3130. check_lib "${gsm_hdr}" gsm_create -lgsm && break;
  3131. done || die "ERROR: libgsm not found"; }
  3132. enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
  3133. enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
  3134. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
  3135. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
  3136. enabled libopencv && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
  3137. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  3138. enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
  3139. enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
  3140. enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
  3141. enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
  3142. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  3143. enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
  3144. enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
  3145. enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
  3146. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  3147. enabled libvpx && {
  3148. enabled libvpx_vp8_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
  3149. die "ERROR: libvpx decoder version must be >=0.9.1"; }
  3150. enabled libvpx_vp8_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
  3151. die "ERROR: libvpx encoder version must be >=0.9.6"; }
  3152. enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
  3153. enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
  3154. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
  3155. { check_cpp_condition x264.h "X264_BUILD >= 118" ||
  3156. die "ERROR: libx264 version must be >= 0.118."; }
  3157. enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
  3158. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  3159. enabled openssl && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
  3160. check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
  3161. check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
  3162. die "ERROR: openssl not found"; }
  3163. if enabled gnutls; then
  3164. { check_lib nettle/bignum.h nettle_mpz_get_str_256 -lnettle -lhogweed -lgmp && enable nettle; } ||
  3165. { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
  3166. fi
  3167. # libdc1394 check
  3168. if enabled libdc1394; then
  3169. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  3170. enable libdc1394_2; } ||
  3171. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  3172. enable libdc1394_1; } ||
  3173. die "ERROR: No version of libdc1394 found "
  3174. fi
  3175. if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
  3176. check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  3177. enable sdl &&
  3178. check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
  3179. fi
  3180. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  3181. check_header linux/fb.h
  3182. check_header linux/videodev2.h
  3183. check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
  3184. check_header sys/videoio.h
  3185. check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
  3186. # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
  3187. # w32api 3.12 had it defined wrong
  3188. check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
  3189. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  3190. { check_header dev/bktr/ioctl_meteor.h &&
  3191. check_header dev/bktr/ioctl_bt848.h; } ||
  3192. { check_header machine/ioctl_meteor.h &&
  3193. check_header machine/ioctl_bt848.h; } ||
  3194. { check_header dev/video/meteor/ioctl_meteor.h &&
  3195. check_header dev/video/bktr/ioctl_bt848.h; } ||
  3196. check_header dev/ic/bt8xx.h
  3197. check_header sndio.h
  3198. check_header sys/soundcard.h
  3199. check_header soundcard.h
  3200. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  3201. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack &&
  3202. check_func jack_port_get_latency_range -ljack
  3203. enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
  3204. if enabled libcdio; then
  3205. check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio || check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio
  3206. fi
  3207. enabled x11grab &&
  3208. require X11 X11/Xlib.h XOpenDisplay -lX11 &&
  3209. require Xext X11/extensions/XShm.h XShmCreateImage -lXext &&
  3210. require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
  3211. # check for VDA header
  3212. if ! disabled vda && check_header VideoDecodeAcceleration/VDADecoder.h; then
  3213. enable vda && add_extralibs -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
  3214. fi
  3215. if ! disabled vdpau && enabled vdpau_vdpau_h; then
  3216. check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
  3217. { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." && disable vdpau; }
  3218. fi
  3219. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  3220. # add some useful compiler flags if supported
  3221. check_cflags -Wdeclaration-after-statement
  3222. check_cflags -Wall
  3223. check_cflags -Wno-parentheses
  3224. check_cflags -Wno-switch
  3225. check_cflags -Wno-format-zero-length
  3226. check_cflags -Wdisabled-optimization
  3227. check_cflags -Wpointer-arith
  3228. check_cflags -Wredundant-decls
  3229. check_cflags -Wno-pointer-sign
  3230. check_cflags -Wcast-qual
  3231. check_cflags -Wwrite-strings
  3232. check_cflags -Wtype-limits
  3233. check_cflags -Wundef
  3234. check_cflags -Wmissing-prototypes
  3235. check_cflags -Wstrict-prototypes
  3236. enabled extra_warnings && check_cflags -Winline
  3237. # add some linker flags
  3238. check_ldflags -Wl,--warn-common
  3239. check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
  3240. test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
  3241. enabled xmm_clobber_test &&
  3242. check_ldflags -Wl,--wrap,avcodec_open2 \
  3243. -Wl,--wrap,avcodec_decode_audio4 \
  3244. -Wl,--wrap,avcodec_decode_video2 \
  3245. -Wl,--wrap,avcodec_decode_subtitle2 \
  3246. -Wl,--wrap,avcodec_encode_audio2 \
  3247. -Wl,--wrap,avcodec_encode_video \
  3248. -Wl,--wrap,avcodec_encode_subtitle \
  3249. -Wl,--wrap,sws_scale ||
  3250. disable xmm_clobber_test
  3251. echo "X{};" > $TMPV
  3252. if test_ldflags -Wl,--version-script,$TMPV; then
  3253. append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
  3254. check_cc <<EOF && enable symver_asm_label
  3255. void ff_foo(void) __asm__ ("av_foo@VERSION");
  3256. void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
  3257. EOF
  3258. check_cc <<EOF && enable symver_gnu_asm
  3259. __asm__(".symver ff_foo,av_foo@VERSION");
  3260. void ff_foo(void) {}
  3261. EOF
  3262. fi
  3263. if [ -z "$optflags" ]; then
  3264. if enabled small; then
  3265. optflags=$cflags_size
  3266. elif enabled optimizations; then
  3267. optflags=$cflags_speed
  3268. else
  3269. optflags=$cflags_noopt
  3270. fi
  3271. fi
  3272. check_optflags(){
  3273. check_cflags "$@"
  3274. enabled lto && check_ldflags "$@"
  3275. }
  3276. if enabled lto; then
  3277. test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
  3278. check_cflags -flto
  3279. check_ldflags -flto $cpuflags
  3280. fi
  3281. check_optflags $optflags
  3282. check_optflags -fno-math-errno
  3283. check_optflags -fno-signed-zeros
  3284. if enabled icc; then
  3285. # Just warnings, no remarks
  3286. check_cflags -w1
  3287. # -wd: Disable following warnings
  3288. # 144, 167, 556: -Wno-pointer-sign
  3289. # 1292: attribute "foo" ignored
  3290. # 1419: external declaration in primary source file
  3291. # 10006: ignoring unknown option -fno-signed-zeros
  3292. # 10148: ignoring unknown option -Wno-parentheses
  3293. # 10156: ignoring option '-W'; no argument required
  3294. check_cflags -wd144,167,556,1292,1419,10006,10148,10156
  3295. # 11030: Warning unknown option --as-needed
  3296. # 10156: ignoring option '-export'; no argument required
  3297. check_ldflags -wd10156,11030
  3298. # Allow to compile with optimizations
  3299. check_ldflags -march=$cpu
  3300. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  3301. enable ebp_available
  3302. if enabled x86_32; then
  3303. icc_version=$($cc -dumpversion)
  3304. test ${icc_version%%.*} -ge 11 &&
  3305. check_cflags -falign-stack=maintain-16-byte ||
  3306. disable aligned_stack
  3307. fi
  3308. elif enabled ccc; then
  3309. # disable some annoying warnings
  3310. add_cflags -msg_disable bitnotint
  3311. add_cflags -msg_disable mixfuncvoid
  3312. add_cflags -msg_disable nonstandcast
  3313. add_cflags -msg_disable unsupieee
  3314. elif enabled gcc; then
  3315. check_optflags -fno-tree-vectorize
  3316. check_cflags -Werror=implicit-function-declaration
  3317. check_cflags -Werror=missing-prototypes
  3318. check_cflags -Werror=return-type
  3319. check_cflags -Werror=declaration-after-statement
  3320. check_cflags -Werror=vla
  3321. elif enabled llvm_gcc; then
  3322. check_cflags -mllvm -stack-alignment=16
  3323. elif enabled clang; then
  3324. check_cflags -mllvm -stack-alignment=16
  3325. check_cflags -Qunused-arguments
  3326. check_cflags -Werror=implicit-function-declaration
  3327. check_cflags -Werror=missing-prototypes
  3328. check_cflags -Werror=return-type
  3329. elif enabled armcc; then
  3330. # 2523: use of inline assembler is deprecated
  3331. add_cflags -W${armcc_opt},--diag_suppress=2523
  3332. add_cflags -W${armcc_opt},--diag_suppress=1207
  3333. add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
  3334. add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
  3335. add_cflags -W${armcc_opt},--diag_suppress=167 # pointer sign
  3336. add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign
  3337. elif enabled tms470; then
  3338. add_cflags -pds=824 -pds=837
  3339. elif enabled pathscale; then
  3340. add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
  3341. elif enabled msvc; then
  3342. enabled x86_32 && disable aligned_stack
  3343. fi
  3344. case $target_os in
  3345. osf1)
  3346. enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
  3347. ;;
  3348. plan9)
  3349. add_cppflags -Dmain=plan9_main
  3350. ;;
  3351. esac
  3352. enabled_any $THREADS_LIST && enable threads
  3353. enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
  3354. check_deps $CONFIG_LIST \
  3355. $CONFIG_EXTRA \
  3356. $HAVE_LIST \
  3357. $ALL_COMPONENTS \
  3358. ! enabled_any memalign posix_memalign aligned_malloc &&
  3359. enabled_any $need_memalign && enable memalign_hack
  3360. echo "install prefix $prefix"
  3361. echo "source path $source_path"
  3362. echo "C compiler $cc"
  3363. echo "ARCH $arch ($cpu)"
  3364. if test "$build_suffix" != ""; then
  3365. echo "build suffix $build_suffix"
  3366. fi
  3367. if test "$extra_version" != ""; then
  3368. echo "version string suffix $extra_version"
  3369. fi
  3370. echo "big-endian ${bigendian-no}"
  3371. echo "runtime cpu detection ${runtime_cpudetect-no}"
  3372. if enabled x86; then
  3373. echo "${yasmexe} ${yasm-no}"
  3374. echo "MMX enabled ${mmx-no}"
  3375. echo "MMXEXT enabled ${mmxext-no}"
  3376. echo "3DNow! enabled ${amd3dnow-no}"
  3377. echo "3DNow! extended enabled ${amd3dnowext-no}"
  3378. echo "SSE enabled ${sse-no}"
  3379. echo "SSSE3 enabled ${ssse3-no}"
  3380. echo "AVX enabled ${avx-no}"
  3381. echo "FMA4 enabled ${fma4-no}"
  3382. echo "CMOV enabled ${cmov-no}"
  3383. echo "CMOV is fast ${fast_cmov-no}"
  3384. echo "EBX available ${ebx_available-no}"
  3385. echo "EBP available ${ebp_available-no}"
  3386. fi
  3387. if enabled arm; then
  3388. echo "ARMv5TE enabled ${armv5te-no}"
  3389. echo "ARMv6 enabled ${armv6-no}"
  3390. echo "ARMv6T2 enabled ${armv6t2-no}"
  3391. echo "VFP enabled ${vfp-no}"
  3392. echo "NEON enabled ${neon-no}"
  3393. fi
  3394. if enabled ppc; then
  3395. echo "AltiVec enabled ${altivec-no}"
  3396. echo "PPC 4xx optimizations ${ppc4xx-no}"
  3397. echo "dcbzl available ${dcbzl-no}"
  3398. fi
  3399. if enabled sparc; then
  3400. echo "VIS enabled ${vis-no}"
  3401. fi
  3402. echo "debug symbols ${debug-no}"
  3403. echo "optimize for size ${small-no}"
  3404. echo "optimizations ${optimizations-no}"
  3405. echo "static ${static-no}"
  3406. echo "shared ${shared-no}"
  3407. echo "new filter support ${avfilter-no}"
  3408. echo "network support ${network-no}"
  3409. echo "threading support ${thread_type-no}"
  3410. echo "safe bitstream reader ${safe_bitstream_reader-no}"
  3411. echo "SDL support ${sdl-no}"
  3412. echo "libdxva2 enabled ${dxva2-no}"
  3413. echo "libva enabled ${vaapi-no}"
  3414. echo "libvdpau enabled ${vdpau-no}"
  3415. echo "AVISynth enabled ${avisynth-no}"
  3416. echo "frei0r enabled ${frei0r-no}"
  3417. echo "gnutls enabled ${gnutls-no}"
  3418. echo "libcdio support ${libcdio-no}"
  3419. echo "libdc1394 support ${libdc1394-no}"
  3420. echo "libfaac enabled ${libfaac-no}"
  3421. echo "libfdk-aac enabled ${libfdk_aac-no}"
  3422. echo "libgsm enabled ${libgsm-no}"
  3423. echo "libilbc enabled ${libilbc-no}"
  3424. echo "libmp3lame enabled ${libmp3lame-no}"
  3425. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  3426. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  3427. echo "libopencv support ${libopencv-no}"
  3428. echo "libopenjpeg enabled ${libopenjpeg-no}"
  3429. echo "libopus enabled ${libopus-no}"
  3430. echo "libpulse enabled ${libpulse-no}"
  3431. echo "librtmp enabled ${librtmp-no}"
  3432. echo "libschroedinger enabled ${libschroedinger-no}"
  3433. echo "libspeex enabled ${libspeex-no}"
  3434. echo "libtheora enabled ${libtheora-no}"
  3435. echo "libvo-aacenc support ${libvo_aacenc-no}"
  3436. echo "libvo-amrwbenc support ${libvo_amrwbenc-no}"
  3437. echo "libvorbis enabled ${libvorbis-no}"
  3438. echo "libvpx enabled ${libvpx-no}"
  3439. echo "libx264 enabled ${libx264-no}"
  3440. echo "libxavs enabled ${libxavs-no}"
  3441. echo "libxvid enabled ${libxvid-no}"
  3442. echo "openssl enabled ${openssl-no}"
  3443. echo "zlib enabled ${zlib-no}"
  3444. echo "bzlib enabled ${bzlib-no}"
  3445. test -n "$random_seed" &&
  3446. echo "random seed ${random_seed}"
  3447. echo
  3448. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  3449. echo "Enabled ${type}s:"
  3450. eval list=\$$(toupper $type)_LIST
  3451. print_enabled '_*' $list | sort | pr -r -3 -t
  3452. echo
  3453. done
  3454. license="LGPL version 2.1 or later"
  3455. if enabled nonfree; then
  3456. license="nonfree and unredistributable"
  3457. elif enabled gplv3; then
  3458. license="GPL version 3 or later"
  3459. elif enabled lgplv3; then
  3460. license="LGPL version 3 or later"
  3461. elif enabled gpl; then
  3462. license="GPL version 2 or later"
  3463. fi
  3464. echo "License: $license"
  3465. echo "Creating config.mak and config.h..."
  3466. test -e Makefile || $ln_s "$source_path/Makefile" .
  3467. config_files="$TMPH config.mak"
  3468. cat > config.mak <<EOF
  3469. # Automatically generated by configure - do not modify!
  3470. LIBAV_CONFIGURATION=$LIBAV_CONFIGURATION
  3471. prefix=$prefix
  3472. LIBDIR=\$(DESTDIR)$libdir
  3473. SHLIBDIR=\$(DESTDIR)$shlibdir
  3474. INCDIR=\$(DESTDIR)$incdir
  3475. BINDIR=\$(DESTDIR)$bindir
  3476. DATADIR=\$(DESTDIR)$datadir
  3477. MANDIR=\$(DESTDIR)$mandir
  3478. SRC_PATH=$source_path
  3479. CC_IDENT=$cc_ident
  3480. ARCH=$arch
  3481. CC=$cc
  3482. AS=$as
  3483. LD=$ld
  3484. DEPCC=$dep_cc
  3485. DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
  3486. DEPAS=$as
  3487. DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
  3488. YASM=$yasmexe
  3489. DEPYASM=$yasmexe
  3490. AR=$ar
  3491. ARFLAGS=$arflags
  3492. AR_O=$ar_o
  3493. RANLIB=$ranlib
  3494. LN_S=$ln_s
  3495. CPPFLAGS=$CPPFLAGS
  3496. CFLAGS=$CFLAGS
  3497. ASFLAGS=$ASFLAGS
  3498. AS_C=$AS_C
  3499. AS_O=$AS_O
  3500. CC_C=$CC_C
  3501. CC_E=$CC_E
  3502. CC_O=$CC_O
  3503. LD_O=$LD_O
  3504. LD_LIB=$LD_LIB
  3505. LD_PATH=$LD_PATH
  3506. DLLTOOL=$dlltool
  3507. LDFLAGS=$LDFLAGS
  3508. LDFLAGS-avserver=$AVSERVERLDFLAGS
  3509. SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
  3510. YASMFLAGS=$YASMFLAGS
  3511. BUILDSUF=$build_suffix
  3512. FULLNAME=$FULLNAME
  3513. LIBPREF=$LIBPREF
  3514. LIBSUF=$LIBSUF
  3515. LIBNAME=$LIBNAME
  3516. SLIBPREF=$SLIBPREF
  3517. SLIBSUF=$SLIBSUF
  3518. EXESUF=$EXESUF
  3519. EXTRA_VERSION=$extra_version
  3520. CCDEP=$CCDEP
  3521. CCDEP_FLAGS=$CCDEP_FLAGS
  3522. ASDEP=$ASDEP
  3523. ASDEP_FLAGS=$ASDEP_FLAGS
  3524. CC_DEPFLAGS=$CC_DEPFLAGS
  3525. AS_DEPFLAGS=$AS_DEPFLAGS
  3526. HOSTCC=$host_cc
  3527. HOSTLD=$host_ld
  3528. HOSTCFLAGS=$host_cflags
  3529. HOSTEXESUF=$HOSTEXESUF
  3530. HOSTLDFLAGS=$host_ldflags
  3531. HOSTLIBS=$host_libs
  3532. DEPHOSTCC=$host_cc
  3533. DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
  3534. HOSTCCDEP=$HOSTCCDEP
  3535. HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
  3536. HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
  3537. HOSTCC_C=$HOSTCC_C
  3538. HOSTCC_O=$HOSTCC_O
  3539. HOSTLD_O=$HOSTLD_O
  3540. TARGET_EXEC=$target_exec
  3541. TARGET_PATH=$target_path
  3542. LIBS-avplay=$sdl_libs
  3543. CFLAGS-avplay=$sdl_cflags
  3544. ZLIB=$($ldflags_filter -lz)
  3545. LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
  3546. EXTRALIBS=$extralibs
  3547. COMPAT_OBJS=$compat_objs
  3548. EXEOBJS=$exeobjs
  3549. INSTALL=install
  3550. LIBTARGET=${LIBTARGET}
  3551. SLIBNAME=${SLIBNAME}
  3552. SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
  3553. SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
  3554. SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
  3555. SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
  3556. SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
  3557. SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
  3558. SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
  3559. SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
  3560. SAMPLES:=${samples:-\$(LIBAV_SAMPLES)}
  3561. EOF
  3562. get_version(){
  3563. lcname=lib${1}
  3564. name=$(toupper $lcname)
  3565. file=$source_path/$lcname/version.h
  3566. eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
  3567. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  3568. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  3569. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  3570. }
  3571. map 'get_version $v' $LIBRARY_LIST
  3572. cat > $TMPH <<EOF
  3573. /* Automatically generated by configure - do not modify! */
  3574. #ifndef LIBAV_CONFIG_H
  3575. #define LIBAV_CONFIG_H
  3576. #define LIBAV_CONFIGURATION "$(c_escape $LIBAV_CONFIGURATION)"
  3577. #define LIBAV_LICENSE "$(c_escape $license)"
  3578. #define AVCONV_DATADIR "$(eval c_escape $datadir)"
  3579. #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
  3580. #define restrict $_restrict
  3581. #define EXTERN_PREFIX "${extern_prefix}"
  3582. #define EXTERN_ASM ${extern_prefix}
  3583. #define SLIBSUF "$SLIBSUF"
  3584. EOF
  3585. test -n "$malloc_prefix" &&
  3586. echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
  3587. if enabled yasm; then
  3588. append config_files $TMPASM
  3589. printf '' >$TMPASM
  3590. fi
  3591. print_config ARCH_ "$config_files" $ARCH_LIST
  3592. print_config HAVE_ "$config_files" $HAVE_LIST
  3593. print_config CONFIG_ "$config_files" $CONFIG_LIST \
  3594. $CONFIG_EXTRA \
  3595. $ALL_COMPONENTS \
  3596. echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH
  3597. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  3598. cp_if_changed $TMPH config.h
  3599. touch .config
  3600. enabled yasm && cp_if_changed $TMPASM config.asm
  3601. cat > $TMPH <<EOF
  3602. /* Generated by ffconf */
  3603. #ifndef AVUTIL_AVCONFIG_H
  3604. #define AVUTIL_AVCONFIG_H
  3605. EOF
  3606. print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
  3607. echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
  3608. cp_if_changed $TMPH libavutil/avconfig.h
  3609. test -n "$WARNINGS" && printf "\n$WARNINGS"
  3610. # build pkg-config files
  3611. pkgconfig_generate(){
  3612. name=$1
  3613. shortname=${name#lib}${build_suffix}
  3614. comment=$2
  3615. version=$3
  3616. libs=$4
  3617. requires=$5
  3618. enabled ${name#lib} || return 0
  3619. mkdir -p $name
  3620. cat <<EOF > $name/$name.pc
  3621. prefix=$prefix
  3622. exec_prefix=\${prefix}
  3623. libdir=$libdir
  3624. includedir=$incdir
  3625. Name: $name
  3626. Description: $comment
  3627. Version: $version
  3628. Requires: $(enabled shared || echo $requires)
  3629. Requires.private: $(enabled shared && echo $requires)
  3630. Conflicts:
  3631. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  3632. Libs.private: $(enabled shared && echo $libs)
  3633. Cflags: -I\${includedir}
  3634. EOF
  3635. cat <<EOF > $name/$name-uninstalled.pc
  3636. prefix=
  3637. exec_prefix=
  3638. libdir=\${pcfiledir}
  3639. includedir=${source_path}
  3640. Name: $name
  3641. Description: $comment
  3642. Version: $version
  3643. Requires: $requires
  3644. Conflicts:
  3645. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  3646. Cflags: -I\${includedir}
  3647. EOF
  3648. }
  3649. pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" "$LIBM"
  3650. pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3651. pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  3652. pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  3653. pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3654. pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3655. pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"