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.

3005 lines
84KB

  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. Standard options:
  55. --help print this message
  56. --logfile=FILE log tests and output to FILE [config.err]
  57. --disable-logging do not log configure debug information
  58. --prefix=PREFIX install in PREFIX [$prefix]
  59. --bindir=DIR install binaries in DIR [PREFIX/bin]
  60. --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]
  61. --libdir=DIR install libs in DIR [PREFIX/lib]
  62. --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
  63. --incdir=DIR install includes in DIR [PREFIX/include]
  64. --mandir=DIR install man page in DIR [PREFIX/share/man]
  65. Configuration options:
  66. --disable-static do not build static libraries [no]
  67. --enable-shared build shared libraries [no]
  68. --enable-gpl allow use of GPL code, the resulting libs
  69. and binaries will be under GPL [no]
  70. --enable-version3 upgrade (L)GPL to version 3 [no]
  71. --enable-nonfree allow use of nonfree code, the resulting libs
  72. and binaries will be unredistributable [no]
  73. --disable-doc do not build documentation
  74. --disable-ffmpeg disable ffmpeg build
  75. --disable-ffplay disable ffplay build
  76. --disable-ffserver disable ffserver build
  77. --enable-postproc enable GPLed postprocessing support [no]
  78. --enable-avfilter video filter support [no]
  79. --enable-avfilter-lavf video filters dependent on avformat [no]
  80. --enable-beosthreads use BeOS threads [no]
  81. --enable-os2threads use OS/2 threads [no]
  82. --enable-pthreads use pthreads [no]
  83. --enable-w32threads use Win32 threads [no]
  84. --enable-x11grab enable X11 grabbing [no]
  85. --disable-network disable network support [no]
  86. --disable-ipv6 disable IPv6 support [no]
  87. --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]
  88. --enable-gray enable full grayscale support (slower color)
  89. --disable-swscale-alpha disable alpha channel support in swscale
  90. --disable-fastdiv disable table-based division
  91. --enable-small optimize for size instead of speed
  92. --disable-aandct disable AAN DCT code
  93. --disable-fft disable FFT code
  94. --disable-golomb disable Golomb code
  95. --disable-lpc disable LPC code
  96. --disable-mdct disable MDCT code
  97. --disable-rdft disable RDFT code
  98. --disable-vaapi disable VAAPI code
  99. --disable-vdpau disable VDPAU code
  100. --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
  101. --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  102. --enable-memalign-hack emulate memalign, interferes with memory debuggers
  103. --enable-beos-netserver enable BeOS netserver
  104. --disable-encoder=NAME disable encoder NAME
  105. --enable-encoder=NAME enable encoder NAME
  106. --disable-encoders disable all encoders
  107. --disable-decoder=NAME disable decoder NAME
  108. --enable-decoder=NAME enable decoder NAME
  109. --disable-decoders disable all decoders
  110. --disable-hwaccel=NAME disable hwaccel NAME
  111. --enable-hwaccel=NAME enable hwaccel NAME
  112. --disable-hwaccels disable all hwaccels
  113. --disable-muxer=NAME disable muxer NAME
  114. --enable-muxer=NAME enable muxer NAME
  115. --disable-muxers disable all muxers
  116. --disable-demuxer=NAME disable demuxer NAME
  117. --enable-demuxer=NAME enable demuxer NAME
  118. --disable-demuxers disable all demuxers
  119. --enable-parser=NAME enable parser NAME
  120. --disable-parser=NAME disable parser NAME
  121. --disable-parsers disable all parsers
  122. --enable-bsf=NAME enable bitstream filter NAME
  123. --disable-bsf=NAME disable bitstream filter NAME
  124. --disable-bsfs disable all bitstream filters
  125. --enable-protocol=NAME enable protocol NAME
  126. --disable-protocol=NAME disable protocol NAME
  127. --disable-protocols disable all protocols
  128. --disable-indev=NAME disable input device NAME
  129. --disable-outdev=NAME disable output device NAME
  130. --disable-indevs disable input devices
  131. --disable-outdevs disable output devices
  132. --disable-devices disable all devices
  133. --enable-filter=NAME enable filter NAME
  134. --disable-filter=NAME disable filter NAME
  135. --disable-filters disable all filters
  136. --list-decoders show all available decoders
  137. --list-encoders show all available encoders
  138. --list-hwaccels show all available hardware accelerators
  139. --list-muxers show all available muxers
  140. --list-demuxers show all available demuxers
  141. --list-parsers show all available parsers
  142. --list-protocols show all available protocols
  143. --list-bsfs show all available bitstream filters
  144. --list-indevs show all available input devices
  145. --list-outdevs show all available output devices
  146. --list-filters show all available filters
  147. External library support:
  148. --enable-avisynth enable reading of AVISynth script files [no]
  149. --enable-bzlib enable bzlib [autodetect]
  150. --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  151. --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  152. --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
  153. and libraw1394 [no]
  154. --enable-libdirac enable Dirac support via libdirac [no]
  155. --enable-libfaac enable FAAC support via libfaac [no]
  156. --enable-libfaad enable FAAD support via libfaad [no]
  157. --enable-libfaadbin open libfaad.so.0 at runtime [no]
  158. --enable-libgsm enable GSM support via libgsm [no]
  159. --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
  160. --enable-libnut enable NUT (de)muxing via libnut,
  161. native (de)muxer exists [no]
  162. --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
  163. --enable-libschroedinger enable Dirac support via libschroedinger [no]
  164. --enable-libspeex enable Speex decoding via libspeex [no]
  165. --enable-libtheora enable Theora encoding via libtheora [no]
  166. --enable-libvorbis enable Vorbis encoding via libvorbis,
  167. native implementation exists [no]
  168. --enable-libx264 enable H.264 encoding via x264 [no]
  169. --enable-libxvid enable Xvid encoding via xvidcore,
  170. native MPEG-4/Xvid encoder exists [no]
  171. --enable-mlib enable Sun medialib [no]
  172. --enable-zlib enable zlib [autodetect]
  173. Advanced options (experts only):
  174. --source-path=PATH path to source code [$source_path]
  175. --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
  176. --enable-cross-compile assume a cross-compiler is used
  177. --sysroot=PATH root of cross-build tree
  178. --sysinclude=PATH location of cross-build system headers
  179. --target-os=OS compiler targets OS [$target_os]
  180. --target-exec=CMD command to run executables on target
  181. --target-path=DIR path to view of build directory on target
  182. --nm=NM use nm tool
  183. --as=AS use assembler AS [$as_default]
  184. --cc=CC use C compiler CC [$cc_default]
  185. --ld=LD use linker LD
  186. --host-cc=HOSTCC use host C compiler HOSTCC
  187. --host-cflags=HCFLAGS use HCFLAGS when compiling for host
  188. --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
  189. --host-libs=HLIBS use libs HLIBS when linking for host
  190. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
  191. --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
  192. --extra-libs=ELIBS add ELIBS [$ELIBS]
  193. --extra-version=STRING version string suffix []
  194. --build-suffix=SUFFIX library name suffix []
  195. --arch=ARCH select architecture [$arch]
  196. --cpu=CPU select the minimum required CPU (affects
  197. instruction selection, may crash on older CPUs)
  198. --enable-powerpc-perf enable performance report on PPC
  199. (requires enabling PMC)
  200. --disable-asm disable all assembler optimizations
  201. --disable-altivec disable AltiVec optimizations
  202. --disable-amd3dnow disable 3DNow! optimizations
  203. --disable-amd3dnowext disable 3DNow! extended optimizations
  204. --disable-mmx disable MMX optimizations
  205. --disable-mmx2 disable MMX2 optimizations
  206. --disable-sse disable SSE optimizations
  207. --disable-ssse3 disable SSSE3 optimizations
  208. --disable-armv5te disable armv5te optimizations
  209. --disable-armv6 disable armv6 optimizations
  210. --disable-armv6t2 disable armv6t2 optimizations
  211. --disable-armvfp disable ARM VFP optimizations
  212. --disable-iwmmxt disable iwmmxt optimizations
  213. --disable-mmi disable MMI optimizations
  214. --disable-neon disable neon optimizations
  215. --disable-vis disable VIS optimizations
  216. --disable-yasm disable use of yasm assembler
  217. --enable-pic build position-independent code
  218. Developer options (useful when working on FFmpeg itself):
  219. --disable-debug disable debugging symbols
  220. --enable-debug=LEVEL set the debug level [$debuglevel]
  221. --enable-gprof enable profiling with gprof [$gprof]
  222. --disable-optimizations disable compiler optimizations
  223. --enable-extra-warnings enable more compiler warnings
  224. --disable-stripping disable stripping of executables and shared libraries
  225. NOTE: Object files are built at the place where configure is launched.
  226. EOF
  227. exit 0
  228. }
  229. log(){
  230. echo "$@" >> $logfile
  231. }
  232. log_file(){
  233. log BEGIN $1
  234. pr -n -t $1 >> $logfile
  235. log END $1
  236. }
  237. echolog(){
  238. log "$@"
  239. echo "$@"
  240. }
  241. die(){
  242. echolog "$@"
  243. cat <<EOF
  244. If you think configure made a mistake, make sure you are using the latest
  245. version from SVN. If the latest version fails, report the problem to the
  246. ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  247. EOF
  248. if disabled logging; then
  249. cat <<EOF
  250. Rerun configure with logging enabled (do not use --disable-logging), and
  251. include the log this produces with your report.
  252. EOF
  253. else
  254. cat <<EOF
  255. Include the log file "$logfile" produced by configure as this will help
  256. solving the problem.
  257. EOF
  258. fi
  259. exit 1
  260. }
  261. # Avoid locale weirdness, besides we really just want to translate ASCII.
  262. toupper(){
  263. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  264. }
  265. tolower(){
  266. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  267. }
  268. c_escape(){
  269. echo "$*" | sed 's/["\\]/\\\0/g'
  270. }
  271. sh_quote(){
  272. v=$(echo "$1" | sed "s/'/'\\\\''/g")
  273. test "$v" = "${v#*[ |&;<>()$\`\\\"\'*?\[\]#~=%]}" || v="'$v'"
  274. echo "$v"
  275. }
  276. filter(){
  277. pat=$1
  278. shift
  279. for v; do
  280. eval "case $v in $pat) echo $v ;; esac"
  281. done
  282. }
  283. set_all(){
  284. value=$1
  285. shift
  286. for var in $*; do
  287. eval $var=$value
  288. done
  289. }
  290. set_weak(){
  291. value=$1
  292. shift
  293. for var; do
  294. eval : \${$var:=$value}
  295. done
  296. }
  297. pushvar(){
  298. for var in $*; do
  299. eval level=\${${var}_level:=0}
  300. eval ${var}_${level}="\$$var"
  301. eval ${var}_level=$(($level+1))
  302. done
  303. }
  304. popvar(){
  305. for var in $*; do
  306. eval level=\${${var}_level:-0}
  307. test $level = 0 && continue
  308. eval level=$(($level-1))
  309. eval $var="\${${var}_${level}}"
  310. eval ${var}_level=$level
  311. eval unset ${var}_${level}
  312. done
  313. }
  314. enable(){
  315. set_all yes $*
  316. }
  317. disable(){
  318. set_all no $*
  319. }
  320. enable_weak(){
  321. set_weak yes $*
  322. }
  323. disable_weak(){
  324. set_weak no $*
  325. }
  326. enable_safe(){
  327. for var; do
  328. enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  329. done
  330. }
  331. disable_safe(){
  332. for var; do
  333. disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  334. done
  335. }
  336. do_enable_deep(){
  337. for var; do
  338. enabled $var && continue
  339. eval sel="\$${var}_select"
  340. eval sgs="\$${var}_suggest"
  341. pushvar var sgs
  342. enable_deep $sel
  343. popvar sgs
  344. enable_deep_weak $sgs
  345. popvar var
  346. done
  347. }
  348. enable_deep(){
  349. do_enable_deep $*
  350. enable $*
  351. }
  352. enable_deep_weak(){
  353. do_enable_deep $*
  354. enable_weak $*
  355. }
  356. enabled(){
  357. test "${1#!}" = "$1" && op== || op=!=
  358. eval test "x\$${1#!}" $op "xyes"
  359. }
  360. disabled(){
  361. test "${1#!}" = "$1" && op== || op=!=
  362. eval test "x\$${1#!}" $op "xno"
  363. }
  364. enabled_all(){
  365. for opt; do
  366. enabled $opt || return 1
  367. done
  368. }
  369. disabled_all(){
  370. for opt; do
  371. disabled $opt || return 1
  372. done
  373. }
  374. enabled_any(){
  375. for opt; do
  376. enabled $opt && return 0
  377. done
  378. }
  379. disabled_any(){
  380. for opt; do
  381. disabled $opt && return 0
  382. done
  383. return 1
  384. }
  385. set_default(){
  386. for opt; do
  387. eval : \${$opt:=\$${opt}_default}
  388. done
  389. }
  390. is_in(){
  391. value=$1
  392. shift
  393. for var in $*; do
  394. [ $var = $value ] && return 0
  395. done
  396. return 1
  397. }
  398. check_deps(){
  399. for cfg; do
  400. cfg="${cfg#!}"
  401. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  402. disabled ${cfg}_checking && continue
  403. enable ${cfg}_checking
  404. eval dep_all="\$${cfg}_deps"
  405. eval dep_any="\$${cfg}_deps_any"
  406. eval dep_sel="\$${cfg}_select"
  407. eval dep_sgs="\$${cfg}_suggest"
  408. eval dep_ifa="\$${cfg}_if"
  409. eval dep_ifn="\$${cfg}_if_any"
  410. pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  411. check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
  412. popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  413. [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
  414. [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
  415. enabled_all $dep_all || disable $cfg
  416. enabled_any $dep_any || disable $cfg
  417. disabled_any $dep_sel && disable $cfg
  418. if enabled $cfg; then
  419. eval dep_extralibs="\$${cfg}_extralibs"
  420. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  421. enable_deep $dep_sel
  422. enable_deep_weak $dep_sgs
  423. fi
  424. disable ${cfg}_checking
  425. done
  426. }
  427. print_config(){
  428. pfx=$1
  429. header=$2
  430. makefile=$3
  431. shift 3
  432. for cfg; do
  433. ucname="$(toupper $cfg)"
  434. if enabled $cfg; then
  435. echo "#define ${pfx}${ucname} 1" >> $header
  436. echo "${pfx}${ucname}=yes" >> $makefile
  437. else
  438. echo "#define ${pfx}${ucname} 0" >> $header
  439. echo "!${pfx}${ucname}=yes" >> $makefile
  440. fi
  441. done
  442. }
  443. flags_saved(){
  444. (: ${SAVE_CFLAGS?}) 2> /dev/null
  445. }
  446. save_flags(){
  447. flags_saved && return
  448. SAVE_CFLAGS="$CFLAGS"
  449. SAVE_LDFLAGS="$LDFLAGS"
  450. SAVE_extralibs="$extralibs"
  451. }
  452. restore_flags(){
  453. flags_saved || return
  454. CFLAGS="$SAVE_CFLAGS"
  455. LDFLAGS="$SAVE_LDFLAGS"
  456. extralibs="$SAVE_extralibs"
  457. unset SAVE_CFLAGS
  458. unset SAVE_LDFLAGS
  459. unset SAVE_extralibs
  460. }
  461. temp_cflags(){
  462. save_flags
  463. CFLAGS="$CFLAGS $*"
  464. }
  465. temp_ldflags(){
  466. save_flags
  467. LDFLAGS="$LDFLAGS $*"
  468. }
  469. temp_extralibs(){
  470. save_flags
  471. extralibs="$extralibs $*"
  472. }
  473. append(){
  474. var=$1
  475. shift
  476. flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
  477. eval "$var=\"\$$var $*\""
  478. }
  479. add_cppflags(){
  480. append CPPFLAGS $($filter_cppflags "$@")
  481. }
  482. add_cflags(){
  483. append CFLAGS $($filter_cflags "$@")
  484. }
  485. add_asflags(){
  486. append ASFLAGS $($filter_asflags "$@")
  487. }
  488. add_ldflags(){
  489. append LDFLAGS "$@"
  490. }
  491. add_extralibs(){
  492. append extralibs "$@"
  493. }
  494. check_cmd(){
  495. log "$@"
  496. "$@" >> $logfile 2>&1
  497. }
  498. check_cc(){
  499. log check_cc "$@"
  500. cat > $TMPC
  501. log_file $TMPC
  502. check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
  503. }
  504. check_cpp(){
  505. log check_cpp "$@"
  506. cat > $TMPC
  507. log_file $TMPC
  508. check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
  509. }
  510. check_as(){
  511. log check_as "$@"
  512. cat > $TMPC
  513. log_file $TMPC
  514. check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
  515. }
  516. check_asm(){
  517. log check_asm "$@"
  518. name="$1"
  519. code="$2"
  520. shift 2
  521. disable $name
  522. check_as "$@" <<EOF && enable $name
  523. void foo(void){ __asm__ volatile($code); }
  524. EOF
  525. }
  526. check_yasm(){
  527. log check_yasm "$@"
  528. echo "$1" > $TMPS
  529. log_file $TMPS
  530. shift 1
  531. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  532. }
  533. check_ld(){
  534. log check_ld "$@"
  535. flags=''
  536. libs=''
  537. for f; do
  538. test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
  539. done
  540. check_cc $($filter_cflags $flags) || return
  541. check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
  542. }
  543. check_cppflags(){
  544. log check_cppflags "$@"
  545. set -- $($filter_cppflags "$@")
  546. check_cc "$@" <<EOF && append CPPFLAGS "$@"
  547. int x;
  548. EOF
  549. }
  550. check_cflags(){
  551. log check_cflags "$@"
  552. set -- $($filter_cflags "$@")
  553. check_cc "$@" <<EOF && append CFLAGS "$@"
  554. int x;
  555. EOF
  556. }
  557. test_ldflags(){
  558. log test_ldflags "$@"
  559. check_ld "$@" <<EOF
  560. int main(void){ return 0; }
  561. EOF
  562. }
  563. check_ldflags(){
  564. log check_ldflags "$@"
  565. test_ldflags "$@" && add_ldflags "$@"
  566. }
  567. check_header(){
  568. log check_header "$@"
  569. header=$1
  570. shift
  571. disable_safe $header
  572. check_cpp "$@" <<EOF && enable_safe $header
  573. #include <$header>
  574. int x;
  575. EOF
  576. }
  577. check_func(){
  578. log check_func "$@"
  579. func=$1
  580. shift
  581. disable $func
  582. check_ld "$@" <<EOF && enable $func
  583. extern int $func();
  584. int main(void){ $func(); }
  585. EOF
  586. }
  587. check_func_headers(){
  588. log check_func_headers "$@"
  589. headers=$1
  590. func=$2
  591. shift 2
  592. disable $func
  593. incs=""
  594. for hdr in $headers; do
  595. incs="$incs
  596. #include <$hdr>"
  597. done
  598. check_ld "$@" <<EOF && enable $func && enable_safe $headers
  599. $incs
  600. int main(int argc, char **argv){
  601. return (long) $func;
  602. }
  603. EOF
  604. }
  605. check_cpp_condition(){
  606. log check_cpp_condition "$@"
  607. header=$1
  608. condition=$2
  609. shift 2
  610. check_cpp $($filter_cppflags "$@") <<EOF
  611. #include <$header>
  612. #if !($condition)
  613. #error "unsatisfied condition: $condition"
  614. #endif
  615. EOF
  616. }
  617. check_lib(){
  618. log check_lib "$@"
  619. header="$1"
  620. func="$2"
  621. shift 2
  622. temp_extralibs "$@"
  623. check_header $header && check_func $func && add_extralibs "$@"
  624. err=$?
  625. restore_flags
  626. return $err
  627. }
  628. check_lib2(){
  629. log check_lib2 "$@"
  630. headers="$1"
  631. func="$2"
  632. shift 2
  633. check_func_headers "$headers" $func "$@" && add_extralibs "$@"
  634. }
  635. check_exec(){
  636. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  637. }
  638. check_exec_crash(){
  639. code=$(cat)
  640. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  641. # are safe but may not be available everywhere. Thus we use
  642. # raise(SIGTERM) instead. The check is run in a subshell so we
  643. # can redirect the "Terminated" message from the shell. SIGBUS
  644. # is not defined by standard C so it is used conditionally.
  645. (check_exec "$@") >> $logfile 2>&1 <<EOF
  646. #include <signal.h>
  647. static void sighandler(int sig){
  648. raise(SIGTERM);
  649. }
  650. int main(void){
  651. signal(SIGILL, sighandler);
  652. signal(SIGFPE, sighandler);
  653. signal(SIGSEGV, sighandler);
  654. #ifdef SIGBUS
  655. signal(SIGBUS, sighandler);
  656. #endif
  657. { $code }
  658. }
  659. EOF
  660. }
  661. check_type(){
  662. log check_type "$@"
  663. headers=$1
  664. type=$2
  665. shift 2
  666. disable_safe "$type"
  667. incs=""
  668. for hdr in $headers; do
  669. incs="$incs
  670. #include <$hdr>"
  671. done
  672. check_cc "$@" <<EOF && enable_safe "$type"
  673. $incs
  674. $type v;
  675. EOF
  676. }
  677. check_struct(){
  678. log check_type "$@"
  679. headers=$1
  680. struct=$2
  681. member=$3
  682. shift 3
  683. disable_safe "${struct}_${member}"
  684. incs=""
  685. for hdr in $headers; do
  686. incs="$incs
  687. #include <$hdr>"
  688. done
  689. check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
  690. $incs
  691. const void *p = &(($struct *)0)->$member;
  692. EOF
  693. }
  694. require(){
  695. name="$1"
  696. header="$2"
  697. func="$3"
  698. shift 3
  699. check_lib $header $func "$@" || die "ERROR: $name not found"
  700. }
  701. require2(){
  702. name="$1"
  703. headers="$2"
  704. func="$3"
  705. shift 3
  706. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  707. }
  708. check_foo_config(){
  709. cfg=$1
  710. pkg=$2
  711. header=$3
  712. func=$4
  713. shift 4
  714. disable $cfg
  715. check_cmd ${pkg}-config --version
  716. err=$?
  717. if test "$err" = 0; then
  718. temp_cflags $(${pkg}-config --cflags)
  719. temp_extralibs $(${pkg}-config --libs)
  720. check_lib "$@" $header $func && enable $cfg
  721. fi
  722. return $err
  723. }
  724. check_host_cc(){
  725. log check_host_cc "$@"
  726. cat > $TMPC
  727. log_file $TMPC
  728. check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
  729. }
  730. check_host_cflags(){
  731. log check_host_cflags "$@"
  732. check_host_cc "$@" <<EOF && append host_cflags "$@"
  733. int x;
  734. EOF
  735. }
  736. apply(){
  737. file=$1
  738. shift
  739. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  740. }
  741. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  742. # system-dependent things.
  743. COMPONENT_LIST="
  744. bsfs
  745. decoders
  746. demuxers
  747. encoders
  748. filters
  749. hwaccels
  750. indevs
  751. muxers
  752. outdevs
  753. parsers
  754. protocols
  755. "
  756. CONFIG_LIST="
  757. $COMPONENT_LIST
  758. aandct
  759. avfilter
  760. avfilter_lavf
  761. avisynth
  762. beos_netserver
  763. bzlib
  764. doc
  765. fastdiv
  766. ffmpeg
  767. ffplay
  768. ffserver
  769. fft
  770. golomb
  771. gpl
  772. gprof
  773. gray
  774. hardcoded_tables
  775. ipv6
  776. libdc1394
  777. libdirac
  778. libfaac
  779. libfaad
  780. libfaadbin
  781. libgsm
  782. libmp3lame
  783. libnut
  784. libopencore_amrnb
  785. libopencore_amrwb
  786. libopenjpeg
  787. libschroedinger
  788. libspeex
  789. libtheora
  790. libvorbis
  791. libx264
  792. libxvid
  793. lpc
  794. mdct
  795. memalign_hack
  796. mlib
  797. mpegaudio_hp
  798. network
  799. nonfree
  800. pic
  801. postproc
  802. powerpc_perf
  803. rdft
  804. runtime_cpudetect
  805. shared
  806. small
  807. static
  808. swscale_alpha
  809. vaapi
  810. vdpau
  811. version3
  812. x11grab
  813. zlib
  814. "
  815. THREADS_LIST='
  816. beosthreads
  817. os2threads
  818. pthreads
  819. w32threads
  820. '
  821. ARCH_LIST='
  822. alpha
  823. arm
  824. avr32
  825. avr32_ap
  826. avr32_uc
  827. bfin
  828. ia64
  829. m68k
  830. mips
  831. mips64
  832. parisc
  833. ppc
  834. ppc64
  835. s390
  836. sh4
  837. sparc
  838. sparc64
  839. x86
  840. x86_32
  841. x86_64
  842. '
  843. ARCH_EXT_LIST='
  844. altivec
  845. amd3dnow
  846. amd3dnowext
  847. armv5te
  848. armv6
  849. armv6t2
  850. armvfp
  851. iwmmxt
  852. mmi
  853. mmx
  854. mmx2
  855. neon
  856. ppc4xx
  857. sse
  858. ssse3
  859. vis
  860. '
  861. HAVE_LIST="
  862. $ARCH_EXT_LIST
  863. $THREADS_LIST
  864. alsa_asoundlib_h
  865. altivec_h
  866. arpa_inet_h
  867. attribute_packed
  868. bigendian
  869. bswap
  870. closesocket
  871. cmov
  872. conio_h
  873. dcbzl
  874. dev_bktr_ioctl_bt848_h
  875. dev_bktr_ioctl_meteor_h
  876. dev_ic_bt8xx_h
  877. dev_video_meteor_ioctl_meteor_h
  878. dev_video_bktr_ioctl_bt848_h
  879. dlfcn_h
  880. dlopen
  881. dos_paths
  882. ebp_available
  883. ebx_available
  884. exp2
  885. exp2f
  886. fast_64bit
  887. fast_clz
  888. fast_cmov
  889. fast_unaligned
  890. fork
  891. getaddrinfo
  892. gethrtime
  893. GetProcessTimes
  894. getrusage
  895. inet_aton
  896. inline_asm
  897. isatty
  898. ldbrx
  899. libdc1394_1
  900. libdc1394_2
  901. llrint
  902. log2
  903. log2f
  904. loongson
  905. lrint
  906. lrintf
  907. lzo1x_999_compress
  908. machine_ioctl_bt848_h
  909. machine_ioctl_meteor_h
  910. malloc_h
  911. memalign
  912. mkstemp
  913. pld
  914. posix_memalign
  915. round
  916. roundf
  917. sdl
  918. sdl_video_size
  919. setmode
  920. socklen_t
  921. soundcard_h
  922. poll_h
  923. struct_addrinfo
  924. struct_sockaddr_storage
  925. sys_mman_h
  926. sys_resource_h
  927. sys_select_h
  928. sys_soundcard_h
  929. sys_videoio_h
  930. ten_operands
  931. termios_h
  932. threads
  933. truncf
  934. vfp_args
  935. VirtualAlloc
  936. winsock2_h
  937. xform_asm
  938. yasm
  939. "
  940. # options emitted with CONFIG_ prefix but not available on command line
  941. CONFIG_EXTRA="
  942. gplv3
  943. lgplv3
  944. "
  945. CMDLINE_SELECT="
  946. $ARCH_EXT_LIST
  947. $CONFIG_LIST
  948. $THREADS_LIST
  949. asm
  950. cross_compile
  951. debug
  952. extra_warnings
  953. logging
  954. optimizations
  955. stripping
  956. yasm
  957. "
  958. PATHS_LIST='
  959. bindir
  960. datadir
  961. incdir
  962. libdir
  963. mandir
  964. prefix
  965. shlibdir
  966. '
  967. CMDLINE_SET="
  968. $PATHS_LIST
  969. arch
  970. as
  971. build_suffix
  972. cc
  973. cpu
  974. cross_prefix
  975. dep_cc
  976. extra_version
  977. host_cc
  978. host_cflags
  979. host_ldflags
  980. host_libs
  981. host_os
  982. ld
  983. logfile
  984. nm
  985. source_path
  986. sysinclude
  987. sysroot
  988. target_exec
  989. target_os
  990. target_path
  991. "
  992. CMDLINE_APPEND="
  993. extra_cflags
  994. "
  995. # code dependency declarations
  996. # architecture extensions
  997. armv5te_deps="arm"
  998. armv6_deps="arm"
  999. armv6t2_deps="arm"
  1000. armvfp_deps="arm"
  1001. iwmmxt_deps="arm"
  1002. neon_deps="arm"
  1003. mmi_deps="mips"
  1004. altivec_deps="ppc"
  1005. ppc4xx_deps="ppc"
  1006. vis_deps="sparc"
  1007. x86_64_select="cmov fast_cmov"
  1008. amd3dnow_deps="mmx"
  1009. amd3dnowext_deps="amd3dnow"
  1010. mmx_deps="x86"
  1011. mmx2_deps="mmx"
  1012. sse_deps="mmx"
  1013. ssse3_deps="sse"
  1014. fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
  1015. fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
  1016. fast_unaligned_if_any="armv6 ppc x86"
  1017. need_memalign="altivec neon sse"
  1018. inline_asm_deps="!tms470"
  1019. # decoders / encoders / hardware accelerators
  1020. aac_decoder_select="fft mdct aac_parser"
  1021. aac_encoder_select="fft mdct"
  1022. ac3_decoder_select="fft mdct ac3_parser"
  1023. alac_encoder_select="lpc"
  1024. atrac3_decoder_select="fft mdct"
  1025. cavs_decoder_select="golomb"
  1026. cook_decoder_select="fft mdct"
  1027. cscd_decoder_suggest="zlib"
  1028. dca_decoder_select="fft mdct"
  1029. dnxhd_encoder_select="aandct"
  1030. dxa_decoder_select="zlib"
  1031. eac3_decoder_select="ac3_decoder"
  1032. eamad_decoder_select="aandct"
  1033. eatgq_decoder_select="aandct"
  1034. eatqi_decoder_select="aandct"
  1035. ffv1_decoder_select="golomb"
  1036. flac_decoder_select="golomb"
  1037. flac_encoder_select="golomb lpc"
  1038. flashsv_decoder_select="zlib"
  1039. flashsv_encoder_select="zlib"
  1040. flv_decoder_select="h263_decoder"
  1041. flv_encoder_select="h263_encoder"
  1042. h261_encoder_select="aandct"
  1043. h263_decoder_select="h263_parser"
  1044. h263_encoder_select="aandct"
  1045. h263_vaapi_hwaccel_deps="va_va_h"
  1046. h263_vaapi_hwaccel_select="vaapi h263_decoder"
  1047. h263i_decoder_select="h263_decoder"
  1048. h263p_encoder_select="h263_encoder"
  1049. h264_decoder_select="golomb"
  1050. h264_vaapi_hwaccel_deps="va_va_h"
  1051. h264_vaapi_hwaccel_select="vaapi"
  1052. h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1053. h264_vdpau_decoder_select="vdpau h264_decoder"
  1054. imc_decoder_select="fft mdct"
  1055. jpegls_decoder_select="golomb"
  1056. jpegls_encoder_select="golomb"
  1057. ljpeg_encoder_select="aandct"
  1058. loco_decoder_select="golomb"
  1059. mjpeg_encoder_select="aandct"
  1060. mlp_decoder_select="mlp_parser"
  1061. mpeg1video_encoder_select="aandct"
  1062. mpeg2video_encoder_select="aandct"
  1063. mpeg4_decoder_select="h263_decoder mpeg4video_parser"
  1064. mpeg4_encoder_select="h263_encoder"
  1065. mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1066. mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
  1067. mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1068. mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
  1069. mpeg2_vaapi_hwaccel_deps="va_va_h"
  1070. mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
  1071. mpeg4_vaapi_hwaccel_deps="va_va_h"
  1072. mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
  1073. mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1074. mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
  1075. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  1076. mpeg_xvmc_decoder_select="mpegvideo_decoder"
  1077. msmpeg4v1_decoder_select="h263_decoder"
  1078. msmpeg4v1_encoder_select="h263_encoder"
  1079. msmpeg4v2_decoder_select="h263_decoder"
  1080. msmpeg4v2_encoder_select="h263_encoder"
  1081. msmpeg4v3_decoder_select="h263_decoder"
  1082. msmpeg4v3_encoder_select="h263_encoder"
  1083. nellymoser_decoder_select="fft mdct"
  1084. nellymoser_encoder_select="fft mdct"
  1085. png_decoder_select="zlib"
  1086. png_encoder_select="zlib"
  1087. qdm2_decoder_select="fft mdct rdft"
  1088. rv10_decoder_select="h263_decoder"
  1089. rv10_encoder_select="h263_encoder"
  1090. rv20_decoder_select="h263_decoder"
  1091. rv20_encoder_select="h263_encoder"
  1092. rv30_decoder_select="golomb"
  1093. rv40_decoder_select="golomb"
  1094. shorten_decoder_select="golomb"
  1095. sonic_decoder_select="golomb"
  1096. sonic_encoder_select="golomb"
  1097. sonic_ls_encoder_select="golomb"
  1098. svq3_decoder_select="golomb"
  1099. svq3_decoder_suggest="zlib"
  1100. theora_decoder_select="vp3_decoder"
  1101. tiff_decoder_suggest="zlib"
  1102. tiff_encoder_suggest="zlib"
  1103. truehd_decoder_select="mlp_decoder"
  1104. tscc_decoder_select="zlib"
  1105. vc1_decoder_select="h263_decoder"
  1106. vc1_vaapi_hwaccel_deps="va_va_h"
  1107. vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
  1108. vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1109. vc1_vdpau_decoder_select="vdpau vc1_decoder"
  1110. vorbis_decoder_select="fft mdct"
  1111. vorbis_encoder_select="fft mdct"
  1112. vp6a_decoder_select="vp6_decoder"
  1113. vp6f_decoder_select="vp6_decoder"
  1114. wmav1_decoder_select="fft mdct"
  1115. wmav1_encoder_select="fft mdct"
  1116. wmav2_decoder_select="fft mdct"
  1117. wmav2_encoder_select="fft mdct"
  1118. wmv1_decoder_select="h263_decoder"
  1119. wmv1_encoder_select="h263_encoder"
  1120. wmv2_decoder_select="h263_decoder"
  1121. wmv2_encoder_select="h263_encoder"
  1122. wmv3_decoder_select="vc1_decoder"
  1123. wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
  1124. wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
  1125. zlib_decoder_select="zlib"
  1126. zlib_encoder_select="zlib"
  1127. zmbv_decoder_select="zlib"
  1128. zmbv_encoder_select="zlib"
  1129. # parsers
  1130. h264_parser_select="golomb"
  1131. # bitstream_filters
  1132. aac_adtstoasc_bsf_select="aac_parser"
  1133. # external libraries
  1134. libdirac_decoder_deps="libdirac !libschroedinger"
  1135. libdirac_encoder_deps="libdirac"
  1136. libfaac_encoder_deps="libfaac"
  1137. libfaad_decoder_deps="libfaad"
  1138. libfaadbin_decoder_extralibs='$ldl'
  1139. libgsm_decoder_deps="libgsm"
  1140. libgsm_encoder_deps="libgsm"
  1141. libgsm_ms_decoder_deps="libgsm"
  1142. libgsm_ms_encoder_deps="libgsm"
  1143. libmp3lame_encoder_deps="libmp3lame"
  1144. libopencore_amrnb_decoder_deps="libopencore_amrnb"
  1145. libopencore_amrnb_encoder_deps="libopencore_amrnb"
  1146. libopencore_amrwb_decoder_deps="libopencore_amrwb"
  1147. libopenjpeg_decoder_deps="libopenjpeg"
  1148. libschroedinger_decoder_deps="libschroedinger"
  1149. libschroedinger_encoder_deps="libschroedinger"
  1150. libspeex_decoder_deps="libspeex"
  1151. libtheora_encoder_deps="libtheora"
  1152. libvorbis_encoder_deps="libvorbis"
  1153. libx264_encoder_deps="libx264"
  1154. libxvid_encoder_deps="libxvid"
  1155. # demuxers / muxers
  1156. ac3_demuxer_deps="ac3_parser"
  1157. asf_stream_muxer_select="asf_muxer"
  1158. avisynth_demuxer_deps="avisynth"
  1159. dirac_demuxer_deps="dirac_parser"
  1160. eac3_demuxer_select="ac3_parser"
  1161. ipod_muxer_select="mov_muxer"
  1162. libnut_demuxer_deps="libnut"
  1163. libnut_muxer_deps="libnut"
  1164. matroska_audio_muxer_select="matroska_muxer"
  1165. matroska_demuxer_suggest="zlib bzlib"
  1166. mov_demuxer_suggest="zlib"
  1167. mp3_demuxer_deps="mpegaudio_parser"
  1168. mp4_muxer_select="mov_muxer"
  1169. mpegtsraw_demuxer_select="mpegts_demuxer"
  1170. mxf_d10_muxer_select="mxf_muxer"
  1171. ogg_demuxer_select="golomb"
  1172. psp_muxer_select="mov_muxer"
  1173. rtsp_demuxer_deps="sdp_demuxer"
  1174. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  1175. spdif_muxer_select="aac_parser"
  1176. tg2_muxer_select="mov_muxer"
  1177. tgp_muxer_select="mov_muxer"
  1178. w64_demuxer_deps="wav_demuxer"
  1179. # indevs / outdevs
  1180. alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1181. alsa_indev_extralibs="-lasound"
  1182. alsa_outdev_deps="alsa_asoundlib_h"
  1183. alsa_outdev_extralibs="-lasound"
  1184. audio_beos_indev_deps="audio_beos"
  1185. audio_beos_indev_extralibs="-lmedia -lbe"
  1186. audio_beos_outdev_deps="audio_beos"
  1187. audio_beos_outdev_extralibs="-lmedia -lbe"
  1188. bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1189. dv1394_indev_deps="dv1394 dv_demuxer"
  1190. jack_indev_deps="jack_jack_h"
  1191. jack_indev_extralibs="-ljack"
  1192. libdc1394_indev_deps="libdc1394"
  1193. oss_indev_deps_any="soundcard_h sys_soundcard_h"
  1194. oss_outdev_deps_any="soundcard_h sys_soundcard_h"
  1195. v4l_indev_deps="linux_videodev_h"
  1196. v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
  1197. vfwcap_indev_deps="capCreateCaptureWindow"
  1198. vfwcap_indev_extralibs="-lvfw32"
  1199. x11_grab_device_indev_deps="x11grab XShmCreateImage"
  1200. x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
  1201. # protocols
  1202. gopher_protocol_deps="network"
  1203. http_protocol_deps="network"
  1204. rtmp_protocol_deps="tcp_protocol"
  1205. rtp_protocol_deps="udp_protocol"
  1206. tcp_protocol_deps="network"
  1207. udp_protocol_deps="network"
  1208. # filters
  1209. movie_filter_deps="avfilter_lavf"
  1210. # programs
  1211. ffplay_deps="sdl"
  1212. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  1213. ffserver_extralibs='$ldl'
  1214. doc_deps="texi2html"
  1215. # default parameters
  1216. logfile="config.err"
  1217. # installation paths
  1218. prefix_default="/usr/local"
  1219. bindir_default='${prefix}/bin'
  1220. datadir_default='${prefix}/share/ffmpeg'
  1221. incdir_default='${prefix}/include'
  1222. libdir_default='${prefix}/lib'
  1223. mandir_default='${prefix}/share/man'
  1224. shlibdir_default="$libdir_default"
  1225. # toolchain
  1226. ar="ar"
  1227. cc_default="gcc"
  1228. cc_version=\"unknown\"
  1229. host_cc_default="gcc"
  1230. ln_s="ln -sf"
  1231. nm_default="nm"
  1232. objformat="elf"
  1233. ranlib="ranlib"
  1234. strip="strip"
  1235. yasmexe="yasm"
  1236. # machine
  1237. arch=$(uname -m)
  1238. cpu="generic"
  1239. # OS
  1240. target_os=$(tolower $(uname -s))
  1241. host_os=$target_os
  1242. # configurable options
  1243. enable asm
  1244. enable debug
  1245. enable doc
  1246. enable fastdiv
  1247. enable ffmpeg
  1248. enable ffplay
  1249. enable ffserver
  1250. enable ipv6
  1251. enable mpegaudio_hp
  1252. enable network
  1253. enable optimizations
  1254. enable protocols
  1255. enable static
  1256. enable stripping
  1257. enable swscale_alpha
  1258. # build settings
  1259. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1260. FFSERVERLDFLAGS=-Wl,-E
  1261. LIBPREF="lib"
  1262. LIBSUF=".a"
  1263. FULLNAME='$(NAME)$(BUILDSUF)'
  1264. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1265. SLIBPREF="lib"
  1266. SLIBSUF=".so"
  1267. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1268. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1269. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1270. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1271. CC_O='-o $@'
  1272. host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
  1273. host_libs='-lm'
  1274. target_path='.'
  1275. # gcc stupidly only outputs the basename of targets with -MM, but we need the
  1276. # full relative path for objects in subdirectories for non-recursive Make.
  1277. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1278. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
  1279. # find source path
  1280. source_path="$(dirname "$0")"
  1281. enable source_path_used
  1282. if test -f configure; then
  1283. source_path="$(pwd)"
  1284. disable source_path_used
  1285. else
  1286. source_path="$(cd "$source_path"; pwd)"
  1287. echo "$source_path" | grep -q '[[:blank:]]' &&
  1288. die "Out of tree builds are impossible with whitespace in source path."
  1289. test -e "$source_path/config.h" &&
  1290. die "Out of tree builds are impossible with config.h in source dir."
  1291. fi
  1292. for v in "$@"; do
  1293. r=${v#*=}
  1294. l=${v%"$r"}
  1295. r=$(sh_quote "$r")
  1296. FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
  1297. done
  1298. find_things(){
  1299. thing=$1
  1300. pattern=$2
  1301. file=$source_path/$3
  1302. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1303. }
  1304. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1305. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1306. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1307. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1308. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1309. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1310. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1311. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1312. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1313. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1314. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1315. enable $ARCH_EXT_LIST \
  1316. $DECODER_LIST \
  1317. $ENCODER_LIST \
  1318. $HWACCEL_LIST \
  1319. $PARSER_LIST \
  1320. $BSF_LIST \
  1321. $DEMUXER_LIST \
  1322. $MUXER_LIST \
  1323. $FILTER_LIST \
  1324. $PROTOCOL_LIST \
  1325. $INDEV_LIST \
  1326. $OUTDEV_LIST \
  1327. die_unknown(){
  1328. echo "Unknown option \"$1\"."
  1329. echo "See $0 --help for available options."
  1330. exit 1
  1331. }
  1332. show_list() {
  1333. suffix=_$1
  1334. shift
  1335. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  1336. exit 0
  1337. }
  1338. for opt do
  1339. optval="${opt#*=}"
  1340. case "$opt" in
  1341. --extra-ldflags=*) add_ldflags $optval
  1342. ;;
  1343. --extra-libs=*) add_extralibs $optval
  1344. ;;
  1345. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1346. ;;
  1347. --enable-debug=*) debuglevel="$optval"
  1348. ;;
  1349. --enable-*=*|--disable-*=*)
  1350. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1351. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1352. eval list=\$$(toupper $thing)_LIST
  1353. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1354. $action $(filter "$name" $list)
  1355. ;;
  1356. --enable-?*|--disable-?*)
  1357. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1358. if is_in $option $COMPONENT_LIST; then
  1359. test $action = disable && action=unset
  1360. eval $action \$$(toupper ${option%s})_LIST
  1361. elif is_in $option $CMDLINE_SELECT; then
  1362. $action $option
  1363. else
  1364. die_unknown $opt
  1365. fi
  1366. ;;
  1367. --list-*)
  1368. NAME="${opt#--list-}"
  1369. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1370. NAME=${NAME%s}
  1371. eval show_list $NAME \$$(toupper $NAME)_LIST
  1372. ;;
  1373. --help|-h) show_help
  1374. ;;
  1375. *)
  1376. optname="${opt%%=*}"
  1377. optname="${optname#--}"
  1378. optname=$(echo "$optname" | sed 's/-/_/g')
  1379. if is_in $optname $CMDLINE_SET; then
  1380. eval $optname='$optval'
  1381. elif is_in $optname $CMDLINE_APPEND; then
  1382. append $optname "$optval"
  1383. else
  1384. die_unknown $opt
  1385. fi
  1386. ;;
  1387. esac
  1388. done
  1389. disabled logging && logfile=/dev/null
  1390. echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
  1391. set >> $logfile
  1392. test -n "$cross_prefix" && enable cross_compile
  1393. ar="${cross_prefix}${ar}"
  1394. cc_default="${cross_prefix}${cc_default}"
  1395. nm_default="${cross_prefix}${nm_default}"
  1396. ranlib="${cross_prefix}${ranlib}"
  1397. strip="${cross_prefix}${strip}"
  1398. sysinclude_default="${sysroot}/usr/include"
  1399. set_default cc nm sysinclude
  1400. enabled cross_compile || host_cc_default=$cc
  1401. set_default host_cc
  1402. exesuf() {
  1403. case $1 in
  1404. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
  1405. esac
  1406. }
  1407. EXESUF=$(exesuf $target_os)
  1408. HOSTEXESUF=$(exesuf $host_os)
  1409. # set temporary file name
  1410. : ${TMPDIR:=$TEMPDIR}
  1411. : ${TMPDIR:=$TMP}
  1412. : ${TMPDIR:=/tmp}
  1413. if ! check_cmd type mktemp; then
  1414. # simple replacement for missing mktemp
  1415. # NOT SAFE FOR GENERAL USE
  1416. mktemp(){
  1417. echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
  1418. }
  1419. fi
  1420. tmpfile(){
  1421. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1422. (set -C; exec > $tmp) 2>/dev/null ||
  1423. die "Unable to create temporary file in $TMPDIR."
  1424. append TMPFILES $tmp
  1425. eval $1=$tmp
  1426. }
  1427. trap 'rm -f -- $TMPFILES' EXIT
  1428. trap exit HUP INT TERM
  1429. tmpfile TMPC .c
  1430. tmpfile TMPE $EXESUF
  1431. tmpfile TMPH .h
  1432. tmpfile TMPO .o
  1433. tmpfile TMPS .S
  1434. tmpfile TMPV .ver
  1435. tmpfile TMPSH .sh
  1436. unset -f mktemp
  1437. # make sure we can execute files in $TMPDIR
  1438. cat > $TMPSH 2>> $logfile <<EOF
  1439. #! /bin/sh
  1440. EOF
  1441. chmod +x $TMPSH >> $logfile 2>&1
  1442. if ! $TMPSH >> $logfile 2>&1; then
  1443. cat <<EOF
  1444. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1445. variable to another directory and make sure that it is not mounted noexec.
  1446. EOF
  1447. die "Sanity test failed."
  1448. fi
  1449. filter_cflags=echo
  1450. filter_cppflags=echo
  1451. filter_asflags=echo
  1452. if $cc -v 2>&1 | grep -qi ^gcc; then
  1453. cc_type=gcc
  1454. cc_version=__VERSION__
  1455. if ! $cc -dumpversion | grep -q '^2\.'; then
  1456. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1457. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1458. fi
  1459. elif $cc --version 2>/dev/null | grep -q Intel; then
  1460. cc_type=icc
  1461. cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
  1462. CC_DEPFLAGS='-MMD'
  1463. AS_DEPFLAGS='-MMD'
  1464. elif $cc -v 2>&1 | grep -q xlc; then
  1465. cc_type=xlc
  1466. cc_version="AV_STRINGIFY(__IBMC__)"
  1467. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1468. cc_type=ccc
  1469. cc_version="AV_STRINGIFY(__DECC_VER)"
  1470. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
  1471. debuglevel=3
  1472. add_ldflags -Wl,-z,now # calls to libots crash without this
  1473. elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  1474. test -d "$sysroot" || die "No valid sysroot specified."
  1475. cc_type=armcc
  1476. cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
  1477. armcc_conf="$PWD/armcc.conf"
  1478. $cc --arm_linux_configure \
  1479. --arm_linux_config_file="$armcc_conf" \
  1480. --configure_sysroot="$sysroot" \
  1481. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  1482. die "Error creating armcc configuration file."
  1483. cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
  1484. as_default="${cross_prefix}gcc"
  1485. CC_DEPFLAGS='-MMD'
  1486. AS_DEPFLAGS='-MMD'
  1487. elif $cc -version 2>/dev/null | grep -q TMS470; then
  1488. cc_type=tms470
  1489. cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
  1490. cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
  1491. CC_O='-fr=$(@D)'
  1492. as_default="${cross_prefix}gcc"
  1493. ld_default="${cross_prefix}gcc"
  1494. TMPO=$(basename $TMPC .c).o
  1495. append TMPFILES $TMPO
  1496. add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
  1497. CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
  1498. AS_DEPFLAGS='-MMD'
  1499. filter_cflags=tms470_flags
  1500. tms470_flags(){
  1501. for flag; do
  1502. case $flag in
  1503. -march=*|-mcpu=*)
  1504. case "${flag#*=}" in
  1505. armv7-a|cortex-a*) echo -mv=7a8 ;;
  1506. armv7-r|cortex-r*) echo -mv=7r4 ;;
  1507. armv7-m|cortex-m*) echo -mv=7m3 ;;
  1508. armv6*|arm11*) echo -mv=6 ;;
  1509. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  1510. echo -mv=5e ;;
  1511. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  1512. esac
  1513. ;;
  1514. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  1515. -mfpu=vfp) echo --float_support=vfpv2 ;;
  1516. -msoft-float) echo --float_support=vfplib ;;
  1517. -Os) echo -O3 -mf=2 ;;
  1518. -O[0-3]) echo $flag -mf=5 ;;
  1519. -g) echo -g -mn ;;
  1520. esac
  1521. done
  1522. }
  1523. elif $cc -v 2>&1 | grep -q clang; then
  1524. cc_type=clang
  1525. cc_version=__VERSION__
  1526. CC_DEPFLAGS='-MMD'
  1527. AS_DEPFLAGS='-MMD'
  1528. elif $cc -V 2>&1 | grep -q Sun; then
  1529. cc_type=suncc
  1530. cc_version="AV_STRINGIFY(__SUNPRO_C)"
  1531. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
  1532. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
  1533. filter_cflags=suncc_flags
  1534. suncc_flags(){
  1535. for flag; do
  1536. case $flag in
  1537. -march=*|-mcpu=*)
  1538. case "${flag#*=}" in
  1539. native) echo -xtarget=native ;;
  1540. v9) echo -xarch=sparc ;;
  1541. ultrasparc) echo -xarch=sparcvis ;;
  1542. ultrasparc3|niagara*) echo -xarch=sparcvis2 ;;
  1543. i586|pentium) echo -xchip=pentium ;;
  1544. i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
  1545. pentium3*|c3-2) echo -xtarget=pentium3 ;;
  1546. pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
  1547. pentium4*) echo -xtarget=pentium4 ;;
  1548. prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
  1549. *-sse3) echo -xarch=sse3 ;;
  1550. core2) echo -xarch=ssse3 -xchip=core2 ;;
  1551. amdfam10|barcelona) echo -xarch=sse4_1 ;;
  1552. athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
  1553. k8|opteron|athlon64|athlon-fx)
  1554. echo -xarch=sse2a ;;
  1555. athlon*) echo -xarch=pentium_proa ;;
  1556. esac
  1557. ;;
  1558. -std=c99) echo -xc99 ;;
  1559. -fomit-frame-pointer) echo -xregs=frameptr ;;
  1560. -fPIC) echo -KPIC -xcode=pic32 ;;
  1561. -Os) echo -O5 -xspace ;;
  1562. -W*,*) echo $flag ;;
  1563. -f*-*|-W*) ;;
  1564. *) echo $flag ;;
  1565. esac
  1566. done
  1567. }
  1568. fi
  1569. test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
  1570. : ${as_default:=$cc}
  1571. : ${dep_cc_default:=$cc}
  1572. : ${ld_default:=$cc}
  1573. set_default as dep_cc ld
  1574. test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
  1575. test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
  1576. add_cflags $extra_cflags
  1577. add_asflags $extra_cflags
  1578. if test -n "$sysroot"; then
  1579. case "$cc_type" in
  1580. gcc)
  1581. add_cppflags --sysroot="$sysroot"
  1582. add_ldflags --sysroot="$sysroot"
  1583. ;;
  1584. tms470)
  1585. add_cppflags -I"$sysinclude"
  1586. add_ldflags --sysroot="$sysroot"
  1587. ;;
  1588. clang)
  1589. add_cppflags -isysroot="$sysroot"
  1590. add_ldflags -isysroot="$sysroot"
  1591. ;;
  1592. esac
  1593. fi
  1594. if test "$cpu" = host; then
  1595. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  1596. case "$cc_type" in
  1597. gcc)
  1598. check_native(){
  1599. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  1600. awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
  1601. }
  1602. cpu=$(check_native -march || check_native -mcpu)
  1603. ;;
  1604. esac
  1605. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  1606. fi
  1607. # Deal with common $arch aliases
  1608. case "$arch" in
  1609. arm*)
  1610. arch="arm"
  1611. ;;
  1612. mips|mipsel|IP*)
  1613. arch="mips"
  1614. ;;
  1615. mips64)
  1616. arch="mips"
  1617. subarch="mips64"
  1618. ;;
  1619. parisc|hppa)
  1620. arch="parisc"
  1621. ;;
  1622. parisc64|hppa64)
  1623. arch="parisc"
  1624. subarch="parisc64"
  1625. ;;
  1626. "Power Macintosh"|ppc|powerpc)
  1627. arch="ppc"
  1628. ;;
  1629. ppc64)
  1630. arch="ppc"
  1631. subarch="ppc64"
  1632. ;;
  1633. s390|s390x)
  1634. arch="s390"
  1635. ;;
  1636. sh4|sh)
  1637. arch="sh4"
  1638. ;;
  1639. sun4u|sparc64)
  1640. arch="sparc"
  1641. subarch="sparc64"
  1642. ;;
  1643. i[3-6]86|i86pc|BePC|x86_64|amd64)
  1644. arch="x86"
  1645. ;;
  1646. esac
  1647. is_in $arch $ARCH_LIST || echo "WARNING: unknown arch $arch"
  1648. enable $arch
  1649. # Add processor-specific flags
  1650. if test "$cpu" = generic; then
  1651. : do nothing
  1652. elif enabled ppc; then
  1653. case $cpu in
  1654. 601|ppc601|PowerPC601)
  1655. cpuflags="-mcpu=601"
  1656. ;;
  1657. 603*|ppc603*|PowerPC603*)
  1658. cpuflags="-mcpu=603"
  1659. ;;
  1660. 604*|ppc604*|PowerPC604*)
  1661. cpuflags="-mcpu=604"
  1662. ;;
  1663. G3|g3|75*|ppc75*|PowerPC75*)
  1664. cpuflags="-mcpu=750 -mpowerpc-gfxopt"
  1665. ;;
  1666. G4|g4|745*|ppc745*|PowerPC745*)
  1667. cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
  1668. ;;
  1669. 74*|ppc74*|PowerPC74*)
  1670. cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
  1671. ;;
  1672. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1673. cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1674. ;;
  1675. Cell|CELL|cell)
  1676. cpuflags="-mcpu=cell"
  1677. enable ldbrx
  1678. ;;
  1679. esac
  1680. elif enabled x86; then
  1681. case $cpu in
  1682. i[345]86|pentium)
  1683. cpuflags="-march=$cpu"
  1684. disable mmx
  1685. ;;
  1686. # targets that do NOT support conditional mov (cmov)
  1687. pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1688. cpuflags="-march=$cpu"
  1689. disable cmov
  1690. ;;
  1691. # targets that do support conditional mov (cmov)
  1692. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10)
  1693. cpuflags="-march=$cpu"
  1694. enable cmov
  1695. enable fast_cmov
  1696. ;;
  1697. # targets that do support conditional mov but on which it's slow
  1698. pentium4|pentium4m|prescott|nocona)
  1699. cpuflags="-march=$cpu"
  1700. enable cmov
  1701. disable fast_cmov
  1702. ;;
  1703. esac
  1704. elif enabled sparc; then
  1705. case $cpu in
  1706. sparc64)
  1707. cpuflags="-mcpu=v9"
  1708. ;;
  1709. esac
  1710. elif enabled arm; then
  1711. case $cpu in
  1712. armv*)
  1713. cpuflags="-march=$cpu"
  1714. ;;
  1715. *)
  1716. cpuflags="-mcpu=$cpu"
  1717. ;;
  1718. esac
  1719. elif enabled alpha; then
  1720. enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
  1721. elif enabled bfin; then
  1722. cpuflags="-mcpu=$cpu"
  1723. elif enabled mips; then
  1724. cpuflags="-march=$cpu"
  1725. elif enabled avr32; then
  1726. case $cpu in
  1727. ap7[02]0[0-2])
  1728. subarch="avr32_ap"
  1729. cpuflags="-mpart=$cpu"
  1730. ;;
  1731. ap)
  1732. subarch="avr32_ap"
  1733. cpuflags="-march=$cpu"
  1734. ;;
  1735. uc3[ab]*)
  1736. subarch="avr32_uc"
  1737. cpuflags="-mcpu=$cpu"
  1738. ;;
  1739. uc)
  1740. subarch="avr32_uc"
  1741. cpuflags="-march=$cpu"
  1742. ;;
  1743. esac
  1744. fi
  1745. add_cflags $cpuflags
  1746. add_asflags $cpuflags
  1747. # compiler sanity check
  1748. check_exec <<EOF
  1749. int main(void){ return 0; }
  1750. EOF
  1751. if test "$?" != 0; then
  1752. echo "$cc is unable to create an executable file."
  1753. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1754. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1755. echo "Only do this if you know what cross compiling means."
  1756. fi
  1757. die "C compiler test failed."
  1758. fi
  1759. add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  1760. check_cflags -std=c99
  1761. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  1762. #include <stdlib.h>
  1763. EOF
  1764. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  1765. #include <stdlib.h>
  1766. EOF
  1767. check_host_cflags -std=c99
  1768. case "$arch" in
  1769. alpha|ia64|mips|parisc|sparc)
  1770. spic=$shared
  1771. ;;
  1772. x86)
  1773. subarch="x86_32"
  1774. check_cc <<EOF && subarch="x86_64"
  1775. int test[(int)sizeof(char*) - 7];
  1776. EOF
  1777. if test "$subarch" = "x86_64"; then
  1778. spic=$shared
  1779. fi
  1780. ;;
  1781. esac
  1782. enable $subarch
  1783. enabled spic && enable pic
  1784. check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
  1785. # OS specific
  1786. case $target_os in
  1787. beos|haiku|zeta)
  1788. prefix_default="$HOME/config"
  1789. # 3 gcc releases known for BeOS, each with ugly bugs
  1790. gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
  1791. case "$gcc_version" in
  1792. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1793. disable mmx
  1794. ;;
  1795. *20010315*) echo "BeBits gcc"
  1796. add_cflags -fno-expensive-optimizations
  1797. ;;
  1798. esac
  1799. SHFLAGS=-nostart
  1800. # enable BeOS things
  1801. enable audio_beos
  1802. # no need for libm, but the inet stuff
  1803. # Check for BONE
  1804. # XXX: actually should check for NOT net_server
  1805. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  1806. network_extralibs="-lbind -lsocket"
  1807. else
  1808. enable beos_netserver
  1809. network_extralibs="-lnet"
  1810. fi ;;
  1811. sunos)
  1812. FFSERVERLDFLAGS=""
  1813. SHFLAGS='-shared -Wl,-h,$$(@F)'
  1814. enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
  1815. network_extralibs="-lsocket -lnsl"
  1816. add_cppflags -D__EXTENSIONS__
  1817. ;;
  1818. netbsd)
  1819. oss_indev_extralibs="-lossaudio"
  1820. oss_outdev_extralibs="-lossaudio"
  1821. ;;
  1822. openbsd)
  1823. enable malloc_aligned
  1824. # On OpenBSD 4.5. the compiler does not use PIC unless
  1825. # explicitly using -fPIC. FFmpeg builds fine without PIC,
  1826. # however the generated executable will not do anything
  1827. # (simply quits with exit-code 1, no crash, no output).
  1828. # Thus explicitly enable PIC here.
  1829. enable pic
  1830. SHFLAGS='-shared'
  1831. oss_indev_extralibs="-lossaudio"
  1832. oss_outdev_extralibs="-lossaudio"
  1833. ;;
  1834. freebsd|dragonfly)
  1835. enable malloc_aligned
  1836. ;;
  1837. bsd/os)
  1838. osextralibs="-lpoll -lgnugetopt"
  1839. strip="strip -d"
  1840. ;;
  1841. darwin)
  1842. enable malloc_aligned
  1843. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1844. strip="strip -x"
  1845. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1846. SLIBSUF=".dylib"
  1847. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1848. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1849. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1850. objformat="macho"
  1851. enabled x86_64 && objformat="macho64"
  1852. enabled_any pic shared ||
  1853. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  1854. ;;
  1855. mingw32*)
  1856. # Only WinXP or greater are supported
  1857. add_cflags -D_WIN32_WINNT=0x0501
  1858. if test $target_os = "mingw32ce"; then
  1859. disable network
  1860. else
  1861. target_os=mingw32
  1862. fi
  1863. LIBTARGET=i386
  1864. if enabled x86_64; then
  1865. enable malloc_aligned
  1866. LIBTARGET=x64
  1867. elif enabled arm; then
  1868. LIBTARGET=arm
  1869. fi
  1870. shlibdir_default="$bindir_default"
  1871. disable ffserver
  1872. SLIBPREF=""
  1873. SLIBSUF=".dll"
  1874. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1875. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1876. SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1877. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1878. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
  1879. install -d "$(LIBDIR)"; \
  1880. install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
  1881. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1882. 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'
  1883. objformat="win32"
  1884. enable dos_paths
  1885. check_cflags -fno-common
  1886. if ! enabled x86_64; then
  1887. check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  1888. die "ERROR: MinGW runtime version must be >= 3.15."
  1889. enabled_any avisynth vfwcap_indev &&
  1890. { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
  1891. die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
  1892. fi
  1893. ;;
  1894. cygwin*)
  1895. target_os=cygwin
  1896. shlibdir_default="$bindir_default"
  1897. SLIBPREF="cyg"
  1898. SLIBSUF=".dll"
  1899. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1900. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1901. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1902. objformat="win32"
  1903. enable dos_paths
  1904. check_cflags -fno-common
  1905. ;;
  1906. *-dos|freedos|opendos)
  1907. disable ffplay ffserver
  1908. disable $INDEV_LIST $OUTDEV_LIST
  1909. network_extralibs="-lsocket"
  1910. objformat="coff"
  1911. enable dos_paths
  1912. ;;
  1913. linux)
  1914. enable dv1394
  1915. ;;
  1916. irix*)
  1917. target_os=irix
  1918. ranlib="echo ignoring ranlib"
  1919. ;;
  1920. os/2*)
  1921. strip="lxlite"
  1922. ln_s="cp -f"
  1923. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1924. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1925. FFSERVERLDFLAGS=""
  1926. LIBSUF="_s.a"
  1927. SLIBPREF=""
  1928. SLIBSUF=".dll"
  1929. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1930. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1931. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1932. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1933. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1934. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1935. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1936. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1937. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1938. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1939. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1940. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1941. enable dos_paths
  1942. ;;
  1943. gnu/kfreebsd)
  1944. ;;
  1945. gnu)
  1946. ;;
  1947. *)
  1948. die "Unknown OS '$target_os'."
  1949. ;;
  1950. esac
  1951. set_default $PATHS_LIST
  1952. add_extralibs $osextralibs
  1953. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1954. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1955. # we need to build at least one lib type
  1956. if ! enabled_any static shared; then
  1957. cat <<EOF
  1958. At least one library type must be built.
  1959. Specify --enable-static to build the static libraries or --enable-shared to
  1960. build the shared libraries as well. To only build the shared libraries specify
  1961. --disable-static in addition to --enable-shared.
  1962. EOF
  1963. exit 1;
  1964. fi
  1965. disabled static && LIBNAME=""
  1966. if enabled_any libfaad libfaadbin ; then
  1967. if check_header faad.h; then
  1968. check_cc <<EOF
  1969. #include <faad.h>
  1970. #ifndef FAAD2_VERSION
  1971. ok faad1
  1972. #endif
  1973. int main(void) { return 0; }
  1974. EOF
  1975. test $? = 0 && enable libfaad2
  1976. else
  1977. die "FAAD test failed."
  1978. fi
  1979. fi
  1980. die_license_disabled() {
  1981. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  1982. }
  1983. die_license_disabled gpl libfaad2
  1984. die_license_disabled gpl libx264
  1985. die_license_disabled gpl libxvid
  1986. die_license_disabled gpl postproc
  1987. die_license_disabled gpl x11grab
  1988. die_license_disabled nonfree libfaac
  1989. die_license_disabled version3 libopencore_amrnb
  1990. die_license_disabled version3 libopencore_amrwb
  1991. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  1992. check_deps $ARCH_EXT_LIST
  1993. disabled optimizations || check_cflags -fomit-frame-pointer
  1994. enable_pic() {
  1995. enable pic
  1996. add_cppflags -DPIC
  1997. add_cflags -fPIC
  1998. add_asflags -fPIC
  1999. }
  2000. enabled pic && enable_pic
  2001. check_cc <<EOF || die "Symbol mangling check failed."
  2002. int ff_extern;
  2003. EOF
  2004. sym=$($nm -P -g $TMPO | grep ff_extern)
  2005. extern_prefix=${sym%%ff_extern*}
  2006. check_cc <<EOF && enable inline_asm
  2007. void foo(void) { __asm__ volatile ("" ::); }
  2008. EOF
  2009. _restrict=
  2010. for restrict_keyword in restrict __restrict__ __restrict; do
  2011. check_cc <<EOF && _restrict=$restrict_keyword && break
  2012. void foo(char * $restrict_keyword p);
  2013. EOF
  2014. done
  2015. check_cc <<EOF && enable attribute_packed
  2016. struct { int x; } __attribute__((packed)) x;
  2017. EOF
  2018. check_cc <<EOF || die "endian test failed"
  2019. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  2020. EOF
  2021. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  2022. if enabled alpha; then
  2023. check_cflags -mieee
  2024. elif enabled arm; then
  2025. check_cflags -marm
  2026. check_ld <<EOF && enable vfp_args
  2027. __asm__ (".eabi_attribute 28, 1");
  2028. int main(void) { return 0; }
  2029. EOF
  2030. # We have to check if pld is a nop and disable it.
  2031. check_asm pld '"pld [r0]"'
  2032. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  2033. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  2034. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  2035. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  2036. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  2037. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  2038. enabled_all armv6t2 shared !pic && enable_pic
  2039. elif enabled ia64; then
  2040. # HACK: currently fails to build if .bss is > 4MB and shared libs are built
  2041. enabled shared && enable_weak hardcoded_tables
  2042. elif enabled mips; then
  2043. check_asm loongson '"dmult.g $1, $2, $3"'
  2044. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  2045. elif enabled ppc; then
  2046. check_asm dcbzl '"dcbzl 0, 1"'
  2047. check_asm ppc4xx '"maclhw r10, r11, r12"'
  2048. check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
  2049. # AltiVec flags: The FSF version of GCC differs from the Apple version
  2050. if enabled altivec; then
  2051. check_cflags -maltivec -mabi=altivec &&
  2052. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  2053. check_cflags -faltivec
  2054. # check if our compiler supports Motorola AltiVec C API
  2055. check_cc <<EOF || disable altivec
  2056. $inc_altivec_h
  2057. int main(void) {
  2058. vector signed int v1, v2, v3;
  2059. v1 = vec_add(v2,v3);
  2060. return 0;
  2061. }
  2062. EOF
  2063. # check if our compiler supports braces for vector declarations
  2064. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  2065. $inc_altivec_h
  2066. int main (void) { (vector int) {1}; return 0; }
  2067. EOF
  2068. fi
  2069. elif enabled sparc; then
  2070. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
  2071. add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  2072. elif enabled x86; then
  2073. # check whether EBP is available on x86
  2074. # As 'i' is stored on the stack, this program will crash
  2075. # if the base pointer is used to access it because the
  2076. # base pointer is cleared in the inline assembly code.
  2077. check_exec_crash <<EOF && enable ebp_available
  2078. volatile int i=0;
  2079. __asm__ volatile (
  2080. "xorl %%ebp, %%ebp"
  2081. ::: "%ebp");
  2082. return i;
  2083. EOF
  2084. # check whether EBX is available on x86
  2085. check_asm ebx_available '""::"b"(0)' &&
  2086. check_asm ebx_available '"":::"%ebx"'
  2087. # check whether more than 10 operands are supported
  2088. check_cc <<EOF && enable ten_operands
  2089. int main(void) {
  2090. int x=0;
  2091. __asm__ volatile(
  2092. ""
  2093. :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
  2094. );
  2095. return 0;
  2096. }
  2097. EOF
  2098. # check whether binutils is new enough to compile SSSE3/MMX2
  2099. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  2100. enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
  2101. check_asm bswap '"bswap %%eax" ::: "%eax"'
  2102. YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
  2103. enabled x86_64 && append YASMFLAGS "-m amd64"
  2104. enabled pic && append YASMFLAGS "-DPIC"
  2105. test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
  2106. case "$objformat" in
  2107. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  2108. esac
  2109. disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
  2110. case "$cpu" in
  2111. athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
  2112. disable fast_clz
  2113. ;;
  2114. esac
  2115. fi
  2116. if check_func dlopen; then
  2117. ldl=
  2118. elif check_func dlopen -ldl; then
  2119. ldl=-ldl
  2120. fi
  2121. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  2122. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  2123. check_func fork
  2124. check_func getaddrinfo $network_extralibs
  2125. check_func gethrtime
  2126. check_func getrusage
  2127. check_func inet_aton $network_extralibs
  2128. check_func isatty
  2129. check_func memalign
  2130. check_func mkstemp
  2131. check_func posix_memalign
  2132. check_func_headers io.h setmode
  2133. check_func_headers lzo/lzo1x.h lzo1x_999_compress
  2134. check_func_headers windows.h GetProcessTimes
  2135. check_func_headers windows.h VirtualAlloc
  2136. check_header conio.h
  2137. check_header dlfcn.h
  2138. check_header malloc.h
  2139. check_header poll.h
  2140. check_header sys/mman.h
  2141. check_header sys/resource.h
  2142. check_header sys/select.h
  2143. check_header termios.h
  2144. check_header vdpau/vdpau.h
  2145. check_header vdpau/vdpau_x11.h
  2146. check_header X11/extensions/XvMClib.h
  2147. if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
  2148. enabled_any $need_memalign ; then
  2149. die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
  2150. fi
  2151. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  2152. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  2153. # check for some common methods of building with pthread support
  2154. # do this before the optional library checks as some of them require pthreads
  2155. if enabled pthreads; then
  2156. if check_func pthread_create; then
  2157. :
  2158. elif check_func pthread_create -pthread; then
  2159. add_cflags -pthread
  2160. add_extralibs -pthread
  2161. elif check_func pthread_create -pthreads; then
  2162. add_cflags -pthreads
  2163. add_extralibs -pthreads
  2164. elif check_func pthread_create -lpthreadGC2; then
  2165. add_extralibs -lpthreadGC2
  2166. elif ! check_lib pthread.h pthread_create -lpthread; then
  2167. die "ERROR: can't find pthreads library"
  2168. fi
  2169. fi
  2170. for thread in $THREADS_LIST; do
  2171. if enabled $thread; then
  2172. test -n "$thread_type" &&
  2173. die "ERROR: Only one thread type must be selected." ||
  2174. thread_type="$thread"
  2175. fi
  2176. done
  2177. check_lib math.h sin -lm
  2178. check_lib va/va.h vaInitialize -lva
  2179. check_func exp2
  2180. check_func exp2f
  2181. check_func llrint
  2182. check_func log2
  2183. check_func log2f
  2184. check_func lrint
  2185. check_func lrintf
  2186. check_func round
  2187. check_func roundf
  2188. check_func truncf
  2189. # these are off by default, so fail if requested and not available
  2190. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  2191. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  2192. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
  2193. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
  2194. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  2195. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  2196. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  2197. enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
  2198. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  2199. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
  2200. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
  2201. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  2202. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  2203. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  2204. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  2205. enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
  2206. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  2207. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
  2208. { check_cpp_condition x264.h "X264_BUILD >= 79" ||
  2209. die "ERROR: libx264 version must be >= 0.79."; }
  2210. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  2211. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  2212. # libdc1394 check
  2213. if enabled libdc1394; then
  2214. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  2215. enable libdc1394_2; } ||
  2216. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  2217. enable libdc1394_1; } ||
  2218. die "ERROR: No version of libdc1394 found "
  2219. fi
  2220. SDL_CONFIG="${cross_prefix}sdl-config"
  2221. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  2222. sdl_cflags=$("${SDL_CONFIG}" --cflags)
  2223. sdl_libs=$("${SDL_CONFIG}" --libs)
  2224. check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
  2225. check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  2226. enable sdl &&
  2227. check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
  2228. fi
  2229. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  2230. if enabled network; then
  2231. check_type "sys/types.h sys/socket.h" socklen_t
  2232. check_type netdb.h "struct addrinfo"
  2233. check_type sys/socket.h "struct sockaddr_storage"
  2234. # Prefer arpa/inet.h over winsock2
  2235. if check_header arpa/inet.h ; then
  2236. check_func closesocket
  2237. elif check_header winsock2.h ; then
  2238. check_func_headers winsock2.h closesocket -lws2 && \
  2239. network_extralibs="-lws2" || \
  2240. { check_func_headers winsock2.h closesocket -lws2_32 && \
  2241. network_extralibs="-lws2_32"; }
  2242. check_type ws2tcpip.h socklen_t
  2243. check_type ws2tcpip.h "struct addrinfo"
  2244. check_type ws2tcpip.h "struct sockaddr_storage"
  2245. else
  2246. disable network
  2247. fi
  2248. fi
  2249. enabled_all network ipv6 && check_ld <<EOF || disable ipv6
  2250. #include <sys/types.h>
  2251. #include <sys/socket.h>
  2252. #include <netinet/in.h>
  2253. #include <netdb.h>
  2254. int main(void) {
  2255. struct sockaddr_storage saddr;
  2256. struct ipv6_mreq mreq6;
  2257. getaddrinfo(0,0,0,0);
  2258. getnameinfo(0,0,0,0,0,0,0);
  2259. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  2260. }
  2261. EOF
  2262. check_header linux/videodev.h
  2263. check_header linux/videodev2.h
  2264. check_header sys/videoio.h
  2265. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  2266. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  2267. { check_header dev/bktr/ioctl_meteor.h &&
  2268. check_header dev/bktr/ioctl_bt848.h; } ||
  2269. { check_header machine/ioctl_meteor.h &&
  2270. check_header machine/ioctl_bt848.h; } ||
  2271. { check_header dev/video/meteor/ioctl_meteor.h &&
  2272. check_header dev/video/bktr/ioctl_bt848.h; } ||
  2273. check_header dev/ic/bt8xx.h
  2274. check_header sys/soundcard.h
  2275. check_header soundcard.h
  2276. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  2277. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
  2278. enabled x11grab &&
  2279. check_header X11/Xlib.h &&
  2280. check_header X11/extensions/XShm.h &&
  2281. check_header X11/extensions/Xfixes.h &&
  2282. check_func XOpenDisplay -lX11 &&
  2283. check_func XShmCreateImage -lX11 -lXext &&
  2284. check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
  2285. if ! disabled vdpau && enabled vdpau_vdpau_h; then
  2286. check_cpp_condition \
  2287. vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
  2288. { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
  2289. disable vdpau; }
  2290. fi
  2291. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  2292. # add some useful compiler flags if supported
  2293. check_cflags -Wdeclaration-after-statement
  2294. check_cflags -Wall
  2295. check_cflags -Wno-switch
  2296. check_cflags -Wdisabled-optimization
  2297. check_cflags -Wpointer-arith
  2298. check_cflags -Wredundant-decls
  2299. check_cflags -Wno-pointer-sign
  2300. check_cflags -Wcast-qual
  2301. check_cflags -Wwrite-strings
  2302. check_cflags -Wtype-limits
  2303. check_cflags -Wundef
  2304. enabled extra_warnings && check_cflags -Winline
  2305. # add some linker flags
  2306. check_ldflags -Wl,--warn-common
  2307. check_ldflags -Wl,--as-needed
  2308. check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  2309. check_ldflags -Wl,-Bsymbolic
  2310. echo "X{};" > $TMPV
  2311. test_ldflags -Wl,--version-script,$TMPV &&
  2312. append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
  2313. if enabled small; then
  2314. check_cflags -Os # not all compilers support -Os
  2315. optimizations="small"
  2316. elif enabled optimizations; then
  2317. if enabled xlc; then
  2318. add_cflags -O5
  2319. add_ldflags -O5
  2320. elif enabled suncc; then
  2321. add_cflags -O5
  2322. elif enabled ccc; then
  2323. add_cflags -fast
  2324. else
  2325. add_cflags -O3
  2326. fi
  2327. fi
  2328. check_cflags -fno-math-errno
  2329. check_cflags -fno-signed-zeros
  2330. if enabled icc; then
  2331. # Just warnings, no remarks
  2332. check_cflags -w1
  2333. # -wd: Disable following warnings
  2334. # 144, 167, 556: -Wno-pointer-sign
  2335. # 10006: ignoring unknown option -fno-signed-zeros
  2336. # 10156: ignoring option '-W'; no argument required
  2337. check_cflags -wd144,167,556,10006,10156
  2338. # 11030: Warning unknown option --as-needed
  2339. # 10156: ignoring option '-export'; no argument required
  2340. check_ldflags -wd10156,11030
  2341. # Allow to compile with optimizations
  2342. check_ldflags -march=$cpu
  2343. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  2344. enable ebp_available
  2345. elif enabled ccc; then
  2346. # disable some annoying warnings
  2347. add_cflags -msg_disable cvtu32to64
  2348. add_cflags -msg_disable embedcomment
  2349. add_cflags -msg_disable needconstext
  2350. add_cflags -msg_disable nomainieee
  2351. add_cflags -msg_disable ptrmismatch1
  2352. add_cflags -msg_disable unreachcode
  2353. elif enabled gcc; then
  2354. check_cflags -fno-tree-vectorize
  2355. elif enabled clang; then
  2356. check_cflags -Qunused-arguments
  2357. fi
  2358. if enabled gprof; then
  2359. add_cflags -p
  2360. add_ldflags -p
  2361. fi
  2362. # Find out if the .align argument is a power of two or not.
  2363. check_asm asmalign_pot '".align 3"'
  2364. enabled_any $DECODER_LIST && enable decoders
  2365. enabled_any $ENCODER_LIST && enable encoders
  2366. enabled_any $HWACCEL_LIST && enable hwaccels
  2367. enabled_any $BSF_LIST && enable bsfs
  2368. enabled_any $DEMUXER_LIST && enable demuxers
  2369. enabled_any $MUXER_LIST && enable muxers
  2370. enabled_any $FILTER_LIST && enable filters
  2371. enabled_any $INDEV_LIST && enable indevs
  2372. enabled_any $OUTDEV_LIST && enable outdevs
  2373. enabled_any $PROTOCOL_LIST && enable protocols
  2374. enabled_any $THREADS_LIST && enable threads
  2375. check_deps $CONFIG_LIST \
  2376. $CONFIG_EXTRA \
  2377. $HAVE_LIST \
  2378. $DECODER_LIST \
  2379. $ENCODER_LIST \
  2380. $HWACCEL_LIST \
  2381. $PARSER_LIST \
  2382. $BSF_LIST \
  2383. $DEMUXER_LIST \
  2384. $MUXER_LIST \
  2385. $FILTER_LIST \
  2386. $INDEV_LIST \
  2387. $OUTDEV_LIST \
  2388. $PROTOCOL_LIST \
  2389. enabled asm || disable $ARCH_LIST $ARCH_EXT_LIST
  2390. echo "install prefix $prefix"
  2391. echo "source path $source_path"
  2392. echo "C compiler $cc"
  2393. echo ".align is power-of-two $asmalign_pot"
  2394. echo "ARCH $arch ($cpu)"
  2395. if test "$build_suffix" != ""; then
  2396. echo "build suffix $build_suffix"
  2397. fi
  2398. if test "$extra_version" != ""; then
  2399. echo "version string suffix $extra_version"
  2400. fi
  2401. echo "big-endian ${bigendian-no}"
  2402. echo "runtime cpu detection ${runtime_cpudetect-no}"
  2403. if enabled x86; then
  2404. echo "yasm ${yasm-no}"
  2405. echo "MMX enabled ${mmx-no}"
  2406. echo "MMX2 enabled ${mmx2-no}"
  2407. echo "3DNow! enabled ${amd3dnow-no}"
  2408. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2409. echo "SSE enabled ${sse-no}"
  2410. echo "SSSE3 enabled ${ssse3-no}"
  2411. echo "CMOV enabled ${cmov-no}"
  2412. echo "CMOV is fast ${fast_cmov-no}"
  2413. echo "EBX available ${ebx_available-no}"
  2414. echo "EBP available ${ebp_available-no}"
  2415. echo "10 operands supported ${ten_operands-no}"
  2416. fi
  2417. if enabled arm; then
  2418. echo "ARMv5TE enabled ${armv5te-no}"
  2419. echo "ARMv6 enabled ${armv6-no}"
  2420. echo "ARMv6T2 enabled ${armv6t2-no}"
  2421. echo "ARM VFP enabled ${armvfp-no}"
  2422. echo "IWMMXT enabled ${iwmmxt-no}"
  2423. echo "NEON enabled ${neon-no}"
  2424. fi
  2425. if enabled mips; then
  2426. echo "MMI enabled ${mmi-no}"
  2427. fi
  2428. if enabled ppc; then
  2429. echo "AltiVec enabled ${altivec-no}"
  2430. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2431. echo "dcbzl available ${dcbzl-no}"
  2432. echo "performance report ${powerpc_perf-no}"
  2433. fi
  2434. if enabled sparc; then
  2435. echo "VIS enabled ${vis-no}"
  2436. fi
  2437. echo "gprof enabled ${gprof-no}"
  2438. echo "debug symbols ${debug-no}"
  2439. echo "strip symbols ${stripping-no}"
  2440. echo "optimizations ${optimizations-no}"
  2441. echo "static ${static-no}"
  2442. echo "shared ${shared-no}"
  2443. echo "postprocessing support ${postproc-no}"
  2444. echo "new filter support ${avfilter-no}"
  2445. echo "filters using lavformat ${avfilter_lavf-no}"
  2446. echo "network support ${network-no}"
  2447. if enabled network; then
  2448. echo "IPv6 support ${ipv6-no}"
  2449. fi
  2450. echo "threading support ${thread_type-no}"
  2451. echo "SDL support ${sdl-no}"
  2452. echo "Sun medialib support ${mlib-no}"
  2453. echo "AVISynth enabled ${avisynth-no}"
  2454. echo "libdc1394 support ${libdc1394-no}"
  2455. echo "libdirac enabled ${libdirac-no}"
  2456. echo "libfaac enabled ${libfaac-no}"
  2457. echo "libfaad enabled ${libfaad-no}"
  2458. echo "libfaad dlopened ${libfaadbin-no}"
  2459. echo "libgsm enabled ${libgsm-no}"
  2460. echo "libmp3lame enabled ${libmp3lame-no}"
  2461. echo "libnut enabled ${libnut-no}"
  2462. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  2463. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  2464. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2465. echo "libschroedinger enabled ${libschroedinger-no}"
  2466. echo "libspeex enabled ${libspeex-no}"
  2467. echo "libtheora enabled ${libtheora-no}"
  2468. echo "libvorbis enabled ${libvorbis-no}"
  2469. echo "libx264 enabled ${libx264-no}"
  2470. echo "libxvid enabled ${libxvid-no}"
  2471. echo "zlib enabled ${zlib-no}"
  2472. echo "bzlib enabled ${bzlib-no}"
  2473. echo
  2474. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  2475. echo "Enabled ${type}s:"
  2476. eval list=\$$(toupper $type)_LIST
  2477. for part in $list; do
  2478. enabled $part && echo ${part%_*}
  2479. done | sort | pr -3 -t
  2480. echo
  2481. done
  2482. license="LGPL version 2.1 or later"
  2483. if enabled nonfree; then
  2484. license="nonfree and unredistributable"
  2485. elif enabled gplv3; then
  2486. license="GPL version 3 or later"
  2487. elif enabled lgplv3; then
  2488. license="LGPL version 3 or later"
  2489. elif enabled gpl; then
  2490. license="GPL version 2 or later"
  2491. fi
  2492. echo "License: $license"
  2493. echo "Creating config.mak and config.h..."
  2494. enabled stripping || strip="echo skipping strip"
  2495. cat > config.mak <<EOF
  2496. # Automatically generated by configure - do not modify!
  2497. ifndef FFMPEG_CONFIG_MAK
  2498. FFMPEG_CONFIG_MAK=1
  2499. FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
  2500. prefix=$prefix
  2501. LIBDIR=\$(DESTDIR)$libdir
  2502. SHLIBDIR=\$(DESTDIR)$shlibdir
  2503. INCDIR=\$(DESTDIR)$incdir
  2504. BINDIR=\$(DESTDIR)$bindir
  2505. DATADIR=\$(DESTDIR)$datadir
  2506. MANDIR=\$(DESTDIR)$mandir
  2507. SRC_PATH="$source_path"
  2508. SRC_PATH_BARE=$source_path
  2509. BUILD_ROOT="$PWD"
  2510. ARCH=$arch
  2511. CC=$cc
  2512. AS=$as
  2513. LD=$ld
  2514. DEPCC=$dep_cc
  2515. YASM=$yasmexe
  2516. AR=$ar
  2517. RANLIB=$ranlib
  2518. LN_S=$ln_s
  2519. STRIP=$strip
  2520. CPPFLAGS=$CPPFLAGS
  2521. CFLAGS=$CFLAGS
  2522. ASFLAGS=$ASFLAGS
  2523. CC_O=$CC_O
  2524. LDFLAGS=$LDFLAGS
  2525. FFSERVERLDFLAGS=$FFSERVERLDFLAGS
  2526. SHFLAGS=$SHFLAGS
  2527. YASMFLAGS=$YASMFLAGS
  2528. BUILDSUF=$build_suffix
  2529. FULLNAME=$FULLNAME
  2530. LIBPREF=$LIBPREF
  2531. LIBSUF=$LIBSUF
  2532. LIBNAME=$LIBNAME
  2533. SLIBPREF=$SLIBPREF
  2534. SLIBSUF=$SLIBSUF
  2535. EXESUF=$EXESUF
  2536. EXTRA_VERSION=$extra_version
  2537. DEPFLAGS=$DEPFLAGS
  2538. CCDEP=$CCDEP
  2539. ASDEP=$ASDEP
  2540. CC_DEPFLAGS=$CC_DEPFLAGS
  2541. AS_DEPFLAGS=$AS_DEPFLAGS
  2542. HOSTCC=$host_cc
  2543. HOSTCFLAGS=$host_cflags
  2544. HOSTEXESUF=$HOSTEXESUF
  2545. HOSTLDFLAGS=$host_ldflags
  2546. HOSTLIBS=$host_libs
  2547. TARGET_EXEC=$target_exec
  2548. TARGET_PATH=$target_path
  2549. SDL_LIBS=$sdl_libs
  2550. SDL_CFLAGS=$sdl_cflags
  2551. LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
  2552. EXTRALIBS=$extralibs
  2553. EOF
  2554. get_version(){
  2555. name=$1
  2556. file=$source_path/$2
  2557. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2558. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2559. lcname=$(tolower $name)
  2560. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2561. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2562. }
  2563. get_version LIBSWSCALE libswscale/swscale.h
  2564. get_version LIBPOSTPROC libpostproc/postprocess.h
  2565. get_version LIBAVCODEC libavcodec/avcodec.h
  2566. get_version LIBAVDEVICE libavdevice/avdevice.h
  2567. get_version LIBAVFORMAT libavformat/avformat.h
  2568. get_version LIBAVUTIL libavutil/avutil.h
  2569. get_version LIBAVFILTER libavfilter/avfilter.h
  2570. enabled shared && cat >> config.mak <<EOF
  2571. LIBTARGET=${LIBTARGET}
  2572. SLIBNAME=${SLIBNAME}
  2573. SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
  2574. SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
  2575. SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
  2576. SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
  2577. SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
  2578. SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
  2579. EOF
  2580. enabled asmalign_pot || align_shift="1 <<"
  2581. cat > $TMPH <<EOF
  2582. /* Automatically generated by configure - do not modify! */
  2583. #ifndef FFMPEG_CONFIG_H
  2584. #define FFMPEG_CONFIG_H
  2585. #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
  2586. #define FFMPEG_LICENSE "$(c_escape $license)"
  2587. #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
  2588. #define CC_TYPE "$cc_type"
  2589. #define CC_VERSION $cc_version
  2590. #define restrict $_restrict
  2591. #define ASMALIGN(ZEROBITS) ".align $align_shift " #ZEROBITS "\\n\\t"
  2592. #define EXTERN_PREFIX "${extern_prefix}"
  2593. #define EXTERN_ASM ${extern_prefix}
  2594. EOF
  2595. if enabled small || disabled optimizations; then
  2596. echo "#define av_always_inline" >> $TMPH
  2597. fi
  2598. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2599. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2600. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2601. $CONFIG_EXTRA \
  2602. $DECODER_LIST \
  2603. $ENCODER_LIST \
  2604. $HWACCEL_LIST \
  2605. $PARSER_LIST \
  2606. $BSF_LIST \
  2607. $DEMUXER_LIST \
  2608. $MUXER_LIST \
  2609. $FILTER_LIST \
  2610. $PROTOCOL_LIST \
  2611. $INDEV_LIST \
  2612. $OUTDEV_LIST \
  2613. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2614. echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
  2615. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2616. cmp -s $TMPH config.h &&
  2617. echo "config.h is unchanged" ||
  2618. mv -f $TMPH config.h
  2619. # build tree in object directory if source path is different from current one
  2620. if enabled source_path_used; then
  2621. DIRS="
  2622. doc
  2623. libavcodec
  2624. libavcodec/$arch
  2625. libavdevice
  2626. libavfilter
  2627. libavformat
  2628. libavutil
  2629. libavutil/$arch
  2630. libpostproc
  2631. libswscale
  2632. libswscale/$arch
  2633. tests
  2634. tools
  2635. "
  2636. FILES="
  2637. Makefile
  2638. common.mak
  2639. subdir.mak
  2640. doc/texi2pod.pl
  2641. libavcodec/Makefile
  2642. libavdevice/Makefile
  2643. libavfilter/Makefile
  2644. libavformat/Makefile
  2645. libavutil/Makefile
  2646. libpostproc/Makefile
  2647. libswscale/Makefile
  2648. "
  2649. for dir in $DIRS ; do
  2650. mkdir -p $dir
  2651. done
  2652. for f in $FILES ; do
  2653. $ln_s "$source_path/$f" $f
  2654. done
  2655. fi
  2656. # build pkg-config files
  2657. pkgconfig_generate(){
  2658. name=$1
  2659. shortname=${name#lib}${build_suffix}
  2660. comment=$2
  2661. version=$3
  2662. libs=$4
  2663. requires=$5
  2664. cat <<EOF > $name/$name.pc
  2665. prefix=$prefix
  2666. exec_prefix=\${prefix}
  2667. libdir=$libdir
  2668. includedir=$incdir
  2669. Name: $name
  2670. Description: $comment
  2671. Version: $version
  2672. Requires: $(enabled shared || echo $requires)
  2673. Requires.private: $(enabled shared && echo $requires)
  2674. Conflicts:
  2675. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  2676. Libs.private: $(enabled shared && echo $libs)
  2677. Cflags: -I\${includedir}
  2678. EOF
  2679. cat <<EOF > $name/$name-uninstalled.pc
  2680. prefix=
  2681. exec_prefix=
  2682. libdir=\${pcfiledir}
  2683. includedir=${source_path}
  2684. Name: $name
  2685. Description: $comment
  2686. Version: $version
  2687. Requires: $requires
  2688. Conflicts:
  2689. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2690. Cflags: -I\${includedir}
  2691. EOF
  2692. }
  2693. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2694. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2695. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  2696. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  2697. enabled avfilter &&
  2698. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2699. enabled postproc &&
  2700. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2701. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"