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.

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