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.

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