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.

2965 lines
83KB

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