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.

3029 lines
85KB

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