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.

2680 lines
78KB

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