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.

3909 lines
113KB

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