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.

4084 lines
118KB

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