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.

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