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.

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