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.

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