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.

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