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.

2984 lines
84KB

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