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.

3962 lines
115KB

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