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.

2683 lines
77KB

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