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.

4010 lines
117KB

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