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.

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