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.

3032 lines
85KB

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