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.

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