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.

2971 lines
83KB

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