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.

3976 lines
119KB

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