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.

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