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.

2665 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. # parsers
  1000. h264_parser_select="golomb"
  1001. # external libraries
  1002. libamr_nb_decoder_deps="libamr_nb"
  1003. libamr_nb_encoder_deps="libamr_nb"
  1004. libamr_wb_decoder_deps="libamr_wb"
  1005. libamr_wb_encoder_deps="libamr_wb"
  1006. libdirac_decoder_deps="libdirac !libschroedinger"
  1007. libdirac_encoder_deps="libdirac"
  1008. libfaac_encoder_deps="libfaac"
  1009. libfaad_decoder_deps="libfaad"
  1010. libfaadbin_decoder_extralibs='$ldl'
  1011. libgsm_decoder_deps="libgsm"
  1012. libgsm_encoder_deps="libgsm"
  1013. libgsm_ms_decoder_deps="libgsm"
  1014. libgsm_ms_encoder_deps="libgsm"
  1015. libmp3lame_encoder_deps="libmp3lame"
  1016. libopencore_amrnb_decoder_deps="libopencore_amrnb"
  1017. libopencore_amrnb_encoder_deps="libopencore_amrnb"
  1018. libopencore_amrwb_decoder_deps="libopencore_amrwb"
  1019. libopenjpeg_decoder_deps="libopenjpeg"
  1020. libschroedinger_decoder_deps="libschroedinger"
  1021. libschroedinger_encoder_deps="libschroedinger"
  1022. libspeex_decoder_deps="libspeex"
  1023. libtheora_encoder_deps="libtheora"
  1024. libvorbis_encoder_deps="libvorbis"
  1025. libx264_encoder_deps="libx264"
  1026. libxvid_encoder_deps="libxvid"
  1027. # demuxers / muxers
  1028. ac3_demuxer_deps="ac3_parser"
  1029. alsa_demuxer_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1030. alsa_demuxer_extralibs="-lasound"
  1031. alsa_muxer_deps="alsa_asoundlib_h"
  1032. alsa_muxer_extralibs="-lasound"
  1033. audio_beos_demuxer_deps="audio_beos"
  1034. audio_beos_demuxer_extralibs="-lmedia -lbe"
  1035. audio_beos_muxer_deps="audio_beos"
  1036. audio_beos_muxer_extralibs="-lmedia -lbe"
  1037. avisynth_demuxer_deps="avisynth"
  1038. bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1039. dirac_demuxer_deps="dirac_parser"
  1040. dv1394_demuxer_deps="dv1394 dv_demuxer"
  1041. jack_demuxer_deps="jack_jack_h"
  1042. jack_demuxer_extralibs="-ljack"
  1043. libdc1394_demuxer_deps="libdc1394"
  1044. libnut_demuxer_deps="libnut"
  1045. libnut_muxer_deps="libnut"
  1046. matroska_demuxer_suggest="zlib bzlib"
  1047. mov_demuxer_suggest="zlib"
  1048. mp3_demuxer_deps="mpegaudio_parser"
  1049. oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
  1050. oss_muxer_deps_any="soundcard_h sys_soundcard_h"
  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. v4l_demuxer_deps="linux_videodev_h"
  1056. v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
  1057. vfwcap_demuxer_deps="capCreateCaptureWindow"
  1058. vfwcap_demuxer_extralibs="-lvfw32"
  1059. x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
  1060. x11_grab_device_demuxer_extralibs="-lX11 -lXext"
  1061. # protocols
  1062. gopher_protocol_deps="network"
  1063. http_protocol_deps="network"
  1064. rtp_protocol_deps="udp_protocol"
  1065. tcp_protocol_deps="network"
  1066. udp_protocol_deps="network"
  1067. # filters
  1068. movie_filter_deps="avfilter_lavf"
  1069. # programs
  1070. ffplay_deps="sdl"
  1071. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  1072. ffserver_extralibs='$ldl'
  1073. # default parameters
  1074. logfile="config.err"
  1075. # installation paths
  1076. prefix_default="/usr/local"
  1077. bindir_default='${prefix}/bin'
  1078. datadir_default='${prefix}/share/ffmpeg'
  1079. incdir_default='${prefix}/include'
  1080. libdir_default='${prefix}/lib'
  1081. mandir_default='${prefix}/share/man'
  1082. shlibdir_default="$libdir_default"
  1083. # toolchain
  1084. ar="ar"
  1085. cc_default="gcc"
  1086. host_cc_default="gcc"
  1087. ln_s="ln -sf"
  1088. nm_default="nm"
  1089. objformat="elf"
  1090. ranlib="ranlib"
  1091. strip="strip"
  1092. yasmexe="yasm"
  1093. # machine
  1094. arch=$(uname -m)
  1095. cpu="generic"
  1096. # OS
  1097. target_os=$(tolower $(uname -s))
  1098. host_os=$target_os
  1099. # configurable options
  1100. enable debug
  1101. enable fastdiv
  1102. enable ffmpeg
  1103. enable ffplay
  1104. enable ffserver
  1105. enable ipv6
  1106. enable mpegaudio_hp
  1107. enable network
  1108. enable optimizations
  1109. enable protocols
  1110. enable static
  1111. enable stripping
  1112. enable swscale_alpha
  1113. # build settings
  1114. add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  1115. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1116. FFSERVERLDFLAGS=-Wl,-E
  1117. LIBPREF="lib"
  1118. LIBSUF=".a"
  1119. FULLNAME='$(NAME)$(BUILDSUF)'
  1120. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1121. SLIBPREF="lib"
  1122. SLIBSUF=".so"
  1123. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1124. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1125. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1126. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1127. host_cflags='-O3 -g -Wall'
  1128. host_libs='-lm'
  1129. target_path='.'
  1130. # gcc stupidly only outputs the basename of targets with -MM, but we need the
  1131. # full relative path for objects in subdirectories for non-recursive Make.
  1132. DEPEND_CMD='$(CC) $(CFLAGS) -MM $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
  1133. # find source path
  1134. source_path="$(dirname "$0")"
  1135. enable source_path_used
  1136. if test -z "$source_path" -o "$source_path" = "." ; then
  1137. source_path="$(pwd)"
  1138. disable source_path_used
  1139. else
  1140. source_path="$(cd "$source_path"; pwd)"
  1141. echo "$source_path" | grep -q '[[:blank:]]' &&
  1142. die "Out of tree builds are impossible with whitespace in source path."
  1143. test -e "$source_path/config.h" &&
  1144. die "Out of tree builds are impossible with config.h in source dir."
  1145. fi
  1146. for v in "$@"; do
  1147. r="${v#*=}"
  1148. l="${v%$r}"
  1149. test "$r" = "${r#* }" || r="'$r'"
  1150. FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
  1151. done
  1152. find_things(){
  1153. thing=$1
  1154. pattern=$2
  1155. file=$source_path/$3
  1156. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1157. }
  1158. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1159. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1160. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1161. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1162. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1163. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1164. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1165. OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
  1166. INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
  1167. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1168. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1169. enable $ARCH_EXT_LIST \
  1170. $DECODER_LIST \
  1171. $ENCODER_LIST \
  1172. $HWACCEL_LIST \
  1173. $PARSER_LIST \
  1174. $BSF_LIST \
  1175. $DEMUXER_LIST \
  1176. $MUXER_LIST \
  1177. $FILTER_LIST \
  1178. $PROTOCOL_LIST \
  1179. $INDEV_LIST \
  1180. $OUTDEV_LIST \
  1181. die_unknown(){
  1182. echo "Unknown option \"$1\"."
  1183. echo "See $0 --help for available options."
  1184. exit 1
  1185. }
  1186. show_list() {
  1187. suffix=_$1
  1188. shift
  1189. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  1190. exit 0
  1191. }
  1192. for opt do
  1193. optval="${opt#*=}"
  1194. case "$opt" in
  1195. --extra-cflags=*) add_cflags $optval
  1196. ;;
  1197. --extra-ldflags=*) add_ldflags $optval
  1198. ;;
  1199. --extra-libs=*) add_extralibs $optval
  1200. ;;
  1201. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1202. ;;
  1203. --enable-debug=*) debuglevel="$optval"
  1204. ;;
  1205. --enable-*=*|--disable-*=*)
  1206. eval $(echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/')
  1207. case "$thing" in
  1208. encoder|decoder|hwaccel|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
  1209. *) die_unknown "$opt" ;;
  1210. esac
  1211. ;;
  1212. --enable-?*|--disable-?*)
  1213. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1214. if is_in $option $COMPONENT_LIST; then
  1215. eval $action \$$(toupper ${option%s})_LIST
  1216. elif is_in $option $CMDLINE_SELECT; then
  1217. $action $option
  1218. else
  1219. die_unknown $opt
  1220. fi
  1221. ;;
  1222. --list-*)
  1223. NAME="${opt#--list-}"
  1224. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1225. NAME=${NAME%s}
  1226. eval show_list $NAME \$$(toupper $NAME)_LIST
  1227. ;;
  1228. --help|-h) show_help
  1229. ;;
  1230. *)
  1231. optname="${opt%%=*}"
  1232. optname="${optname#--}"
  1233. optname=$(echo "$optname" | sed 's/-/_/g')
  1234. is_in $optname $CMDLINE_SET || die_unknown $opt
  1235. eval $optname='$optval'
  1236. ;;
  1237. esac
  1238. done
  1239. disabled logging && logfile=/dev/null
  1240. echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
  1241. set >> $logfile
  1242. test -n "$cross_prefix" && enable cross_compile
  1243. ar="${cross_prefix}${ar}"
  1244. cc_default="${cross_prefix}${cc_default}"
  1245. nm_default="${cross_prefix}${nm_default}"
  1246. ranlib="${cross_prefix}${ranlib}"
  1247. strip="${cross_prefix}${strip}"
  1248. sysinclude_default="${sysroot}/usr/include"
  1249. set_default cc nm sysinclude
  1250. as_default=$cc
  1251. enabled cross_compile || host_cc_default=$cc
  1252. set_default host_cc
  1253. exesuf() {
  1254. case $1 in
  1255. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
  1256. esac
  1257. }
  1258. EXESUF=$(exesuf $target_os)
  1259. HOSTEXESUF=$(exesuf $host_os)
  1260. # set temporary file name
  1261. : ${TMPDIR:=$TEMPDIR}
  1262. : ${TMPDIR:=$TMP}
  1263. : ${TMPDIR:=/tmp}
  1264. if ! check_cmd type mktemp; then
  1265. # simple replacement for missing mktemp
  1266. # NOT SAFE FOR GENERAL USE
  1267. mktemp(){
  1268. echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
  1269. }
  1270. fi
  1271. tmpfile(){
  1272. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1273. (set -C; exec > $tmp) 2>/dev/null ||
  1274. die "Unable to create temoporary file in $TMPDIR."
  1275. append TMPFILES $tmp
  1276. eval $1=$tmp
  1277. }
  1278. trap 'rm -f -- $TMPFILES' EXIT
  1279. trap exit HUP INT TERM
  1280. tmpfile TMPC .c
  1281. tmpfile TMPE $EXESUF
  1282. tmpfile TMPH .h
  1283. tmpfile TMPO .o
  1284. tmpfile TMPS .S
  1285. tmpfile TMPSH .sh
  1286. unset -f mktemp
  1287. # make sure we can execute files in $TMPDIR
  1288. cat > $TMPSH 2>> $logfile <<EOF
  1289. #! /bin/sh
  1290. EOF
  1291. chmod +x $TMPSH >> $logfile 2>&1
  1292. if ! $TMPSH >> $logfile 2>&1; then
  1293. cat <<EOF
  1294. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1295. variable to another directory and make sure that it is not mounted noexec.
  1296. EOF
  1297. die "Sanity test failed."
  1298. fi
  1299. if $cc --version 2>/dev/null | grep -qi gcc; then
  1300. cc_type=gcc
  1301. elif $cc --version 2>/dev/null | grep -q Intel; then
  1302. cc_type=icc
  1303. elif $cc -v 2>&1 | grep -q xlc; then
  1304. cc_type=xlc
  1305. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1306. cc_type=ccc
  1307. DEPEND_CMD='$(CC) $(CFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
  1308. debuglevel=3
  1309. add_ldflags -Wl,-z,now # calls to libots crash without this
  1310. elif $cc --vsn 2>/dev/null | grep -q RVCT; then
  1311. test -d "$sysroot" || die "No valid sysroot specified."
  1312. cc_type=armcc
  1313. armcc_conf="$PWD/armcc.conf"
  1314. $cc --arm_linux_configure \
  1315. --arm_linux_config_file="$armcc_conf" \
  1316. --configure_sysroot="$sysroot" \
  1317. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  1318. die "Error creating armcc configuration file."
  1319. cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
  1320. as_default="${cross_prefix}gcc"
  1321. fi
  1322. test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
  1323. set_default as
  1324. if test -n "$sysroot"; then
  1325. case "$cc_type" in
  1326. gcc)
  1327. add_cflags --sysroot="$sysroot"
  1328. add_ldflags --sysroot="$sysroot"
  1329. ;;
  1330. esac
  1331. fi
  1332. # compiler sanity check
  1333. check_exec <<EOF
  1334. int main(void){ return 0; }
  1335. EOF
  1336. if test "$?" != 0; then
  1337. echo "$cc is unable to create an executable file."
  1338. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1339. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1340. echo "Only do this if you know what cross compiling means."
  1341. fi
  1342. die "C compiler test failed."
  1343. fi
  1344. check_cflags -std=c99
  1345. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cflags -D_FILE_OFFSET_BITS=64
  1346. #include <stdlib.h>
  1347. EOF
  1348. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cflags -D_LARGEFILE_SOURCE
  1349. #include <stdlib.h>
  1350. EOF
  1351. case "$arch" in
  1352. alpha)
  1353. arch="alpha"
  1354. enable fast_64bit
  1355. check_cflags -mieee
  1356. ;;
  1357. arm|armv[4567]*l)
  1358. arch="arm"
  1359. ;;
  1360. avr32)
  1361. ;;
  1362. bfin)
  1363. arch="bfin"
  1364. ;;
  1365. ia64)
  1366. arch="ia64"
  1367. enable fast_64bit
  1368. ;;
  1369. m68k)
  1370. arch="m68k"
  1371. ;;
  1372. mips|mipsel|IP*)
  1373. arch="mips"
  1374. ;;
  1375. mips64)
  1376. arch="mips"
  1377. subarch="mips64"
  1378. enable fast_64bit
  1379. ;;
  1380. parisc|hppa)
  1381. arch="parisc"
  1382. ;;
  1383. parisc64|hppa64)
  1384. arch="parisc"
  1385. enable fast_64bit
  1386. ;;
  1387. "Power Macintosh"|ppc|powerpc)
  1388. arch="ppc"
  1389. enable fast_unaligned
  1390. ;;
  1391. ppc64)
  1392. arch="ppc"
  1393. subarch="ppc64"
  1394. enable fast_64bit
  1395. enable fast_unaligned
  1396. ;;
  1397. s390|s390x)
  1398. arch="s390"
  1399. ;;
  1400. sh4|sh)
  1401. arch="sh4"
  1402. ;;
  1403. sparc)
  1404. arch="sparc"
  1405. ;;
  1406. sun4u|sparc64)
  1407. arch="sparc"
  1408. subarch="sparc64"
  1409. enable fast_64bit
  1410. ;;
  1411. i386|i486|i586|i686|i86pc|BePC)
  1412. arch="x86"
  1413. subarch="x86_32"
  1414. enable fast_unaligned
  1415. ;;
  1416. x86_64|amd64)
  1417. arch="x86"
  1418. subarch="x86_32"
  1419. enable cmov
  1420. enable fast_cmov
  1421. enable fast_unaligned
  1422. check_cc <<EOF && enable fast_64bit && subarch="x86_64"
  1423. int test[sizeof(char*) - 7];
  1424. EOF
  1425. ;;
  1426. *)
  1427. arch="unknown"
  1428. ;;
  1429. esac
  1430. enable $arch $subarch
  1431. # OS specific
  1432. case $target_os in
  1433. beos|haiku|zeta)
  1434. prefix_default="$HOME/config"
  1435. # helps building libavcodec
  1436. add_cflags -DPIC -fomit-frame-pointer
  1437. # 3 gcc releases known for BeOS, each with ugly bugs
  1438. gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
  1439. case "$gcc_version" in
  1440. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1441. disable mmx
  1442. ;;
  1443. *20010315*) echo "BeBits gcc"
  1444. add_cflags -fno-expensive-optimizations
  1445. ;;
  1446. esac
  1447. SHFLAGS=-nostart
  1448. # enable BeOS things
  1449. enable audio_beos
  1450. # no need for libm, but the inet stuff
  1451. # Check for BONE
  1452. # XXX: actually should check for NOT net_server
  1453. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  1454. network_extralibs="-lbind -lsocket"
  1455. else
  1456. enable beos_netserver
  1457. network_extralibs="-lnet"
  1458. fi ;;
  1459. sunos)
  1460. FFSERVERLDFLAGS=""
  1461. SHFLAGS='-shared -Wl,-h,$$(@F)'
  1462. network_extralibs="-lsocket -lnsl"
  1463. add_cflags -D__EXTENSIONS__
  1464. ;;
  1465. netbsd)
  1466. oss_demuxer_extralibs="-lossaudio"
  1467. oss_muxer_extralibs="-lossaudio"
  1468. ;;
  1469. openbsd)
  1470. disable need_memalign
  1471. LIBOBJFLAGS='$(PIC)'
  1472. SHFLAGS='-shared'
  1473. oss_demuxer_extralibs="-lossaudio"
  1474. oss_muxer_extralibs="-lossaudio"
  1475. ;;
  1476. freebsd)
  1477. disable need_memalign
  1478. ;;
  1479. bsd/os)
  1480. osextralibs="-lpoll -lgnugetopt"
  1481. strip="strip -d"
  1482. ;;
  1483. darwin)
  1484. disable need_memalign
  1485. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1486. strip="strip -x"
  1487. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1488. SLIBSUF=".dylib"
  1489. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1490. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1491. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1492. objformat="macho"
  1493. enabled x86_64 && objformat="macho64"
  1494. ;;
  1495. mingw32*)
  1496. target_os=mingw32
  1497. LIBTARGET=i386
  1498. if enabled x86_64; then
  1499. disable need_memalign
  1500. LIBTARGET=x64
  1501. fi
  1502. shlibdir_default="$bindir_default"
  1503. disable ffserver
  1504. SLIBPREF=""
  1505. SLIBSUF=".dll"
  1506. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1507. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1508. SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1509. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1510. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
  1511. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1512. 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'
  1513. objformat="win32"
  1514. enable dos_paths
  1515. check_cflags -fno-common
  1516. if ! enabled x86_64; then
  1517. check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  1518. die "ERROR: MinGW runtime version must be >= 3.15."
  1519. enabled_any avisynth vfwcap_demuxer &&
  1520. { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
  1521. die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
  1522. fi
  1523. ;;
  1524. cygwin*)
  1525. target_os=cygwin
  1526. shlibdir_default="$bindir_default"
  1527. SLIBPREF="cyg"
  1528. SLIBSUF=".dll"
  1529. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1530. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1531. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1532. objformat="win32"
  1533. enable dos_paths
  1534. check_cflags -fno-common
  1535. ;;
  1536. *-dos|freedos|opendos)
  1537. disable ffplay ffserver
  1538. disable $INDEV_LIST $OUTDEV_LIST
  1539. network_extralibs="-lsocket"
  1540. objformat="coff"
  1541. enable dos_paths
  1542. ;;
  1543. linux)
  1544. enable dv1394
  1545. ;;
  1546. irix*)
  1547. target_os=irix
  1548. ranlib="echo ignoring ranlib"
  1549. ;;
  1550. os/2*)
  1551. strip="lxlite"
  1552. ln_s="cp -f"
  1553. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1554. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1555. FFSERVERLDFLAGS=""
  1556. LIBSUF="_s.a"
  1557. SLIBPREF=""
  1558. SLIBSUF=".dll"
  1559. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1560. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1561. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1562. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1563. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1564. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1565. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1566. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1567. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1568. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1569. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1570. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1571. enable dos_paths
  1572. ;;
  1573. gnu/kfreebsd)
  1574. ;;
  1575. gnu)
  1576. ;;
  1577. *)
  1578. die "Unknown OS '$target_os'."
  1579. ;;
  1580. esac
  1581. set_default $PATHS_LIST
  1582. add_extralibs $osextralibs
  1583. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1584. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1585. # we need to build at least one lib type
  1586. if ! enabled_any static shared; then
  1587. cat <<EOF
  1588. At least one library type must be built.
  1589. Specify --enable-static to build the static libraries or --enable-shared to
  1590. build the shared libraries as well. To only build the shared libraries specify
  1591. --disable-static in addition to --enable-shared.
  1592. EOF
  1593. exit 1;
  1594. fi
  1595. disabled static && LIBNAME=""
  1596. if enabled_any libfaad libfaadbin ; then
  1597. if check_header faad.h; then
  1598. check_cc <<EOF
  1599. #include <faad.h>
  1600. #ifndef FAAD2_VERSION
  1601. ok faad1
  1602. #endif
  1603. int main(void) { return 0; }
  1604. EOF
  1605. test $? = 0 && enable libfaad2
  1606. else
  1607. die "FAAD test failed."
  1608. fi
  1609. fi
  1610. die_license_disabled() {
  1611. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  1612. }
  1613. die_license_disabled gpl libfaad2
  1614. die_license_disabled gpl libx264
  1615. die_license_disabled gpl libxvid
  1616. die_license_disabled gpl postproc
  1617. die_license_disabled gpl x11grab
  1618. die_license_disabled nonfree libamr_nb
  1619. die_license_disabled nonfree libamr_wb
  1620. die_license_disabled nonfree libfaac
  1621. die_license_disabled version3 libopencore_amrnb
  1622. die_license_disabled version3 libopencore_amrwb
  1623. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  1624. check_deps $ARCH_EXT_LIST
  1625. test -z "$need_memalign" && need_memalign="$mmx"
  1626. #Darwin CC versions
  1627. if test $target_os = darwin; then
  1628. if enabled xlc; then
  1629. add_cflags -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto
  1630. else
  1631. add_cflags -pipe
  1632. check_cflags -force_cpusubtype_ALL
  1633. check_cflags -Wno-sign-compare
  1634. enabled shared || check_cflags -mdynamic-no-pic
  1635. fi
  1636. fi
  1637. disabled optimizations || check_cflags -fomit-frame-pointer
  1638. # Add processor-specific flags
  1639. if test $cpu != "generic"; then
  1640. warn_altivec(){
  1641. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1642. }
  1643. case $cpu in
  1644. 601|ppc601|PowerPC601)
  1645. add_cflags -mcpu=601
  1646. warn_altivec enabled PPC601
  1647. ;;
  1648. 603*|ppc603*|PowerPC603*)
  1649. add_cflags -mcpu=603
  1650. warn_altivec enabled PPC603
  1651. ;;
  1652. 604*|ppc604*|PowerPC604*)
  1653. add_cflags -mcpu=604
  1654. warn_altivec enabled PPC604
  1655. ;;
  1656. G3|g3|75*|ppc75*|PowerPC75*)
  1657. add_cflags -mcpu=750 -mpowerpc-gfxopt
  1658. warn_altivec enabled PPC75x
  1659. ;;
  1660. G4|g4|745*|ppc745*|PowerPC745*)
  1661. add_cflags -mcpu=7450 -mpowerpc-gfxopt
  1662. warn_altivec disabled PPC745x
  1663. ;;
  1664. 74*|ppc74*|PowerPC74*)
  1665. add_cflags -mcpu=7400 -mpowerpc-gfxopt
  1666. warn_altivec disabled PPC74xx
  1667. ;;
  1668. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1669. add_cflags -mcpu=970 -mpowerpc-gfxopt -mpowerpc64
  1670. warn_altivec disabled PPC970
  1671. ;;
  1672. Cell|CELL|cell)
  1673. add_cflags -mcpu=cell
  1674. warn_altivec disabled Cell
  1675. enable ldbrx
  1676. ;;
  1677. # targets that do NOT support conditional mov (cmov)
  1678. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1679. add_cflags -march=$cpu
  1680. disable cmov
  1681. ;;
  1682. # targets that do support conditional mov (cmov)
  1683. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1684. add_cflags -march=$cpu
  1685. enable cmov
  1686. enable fast_cmov
  1687. ;;
  1688. # targets that do support conditional mov but on which it's slow
  1689. pentium4|pentium4m|prescott|nocona)
  1690. add_cflags -march=$cpu
  1691. enable cmov
  1692. disable fast_cmov
  1693. ;;
  1694. sparc64)
  1695. add_cflags -mcpu=v9
  1696. ;;
  1697. arm11*|cortex*)
  1698. add_cflags -mcpu=$cpu
  1699. enable fast_unaligned
  1700. ;;
  1701. armv*)
  1702. add_cflags -march=$cpu
  1703. ;;
  1704. arm*)
  1705. add_cflags -mcpu=$cpu
  1706. ;;
  1707. ev4|ev45|ev5|ev56|pca56|ev6|ev67)
  1708. enabled ccc && add_cflags -arch $cpu || add_cflags -mcpu=$cpu
  1709. ;;
  1710. bf*)
  1711. add_cflags -mcpu=$cpu
  1712. ;;
  1713. mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
  1714. add_cflags -march=$cpu
  1715. ;;
  1716. *)
  1717. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1718. ;;
  1719. esac
  1720. fi
  1721. check_cc <<EOF || die "Symbol mangling check failed."
  1722. int ff_extern;
  1723. EOF
  1724. sym=$($nm -P -g $TMPO | grep ff_extern)
  1725. extern_prefix=${sym%%ff_extern*}
  1726. check_cc <<EOF && enable inline_asm
  1727. void foo(void) { __asm__ volatile ("" ::); }
  1728. EOF
  1729. if enabled x86; then
  1730. # check whether EBP is available on x86
  1731. # As 'i' is stored on the stack, this program will crash
  1732. # if the base pointer is used to access it because the
  1733. # base pointer is cleared in the inline assembly code.
  1734. check_exec_crash <<EOF && enable ebp_available
  1735. volatile int i=0;
  1736. __asm__ volatile (
  1737. "xorl %%ebp, %%ebp"
  1738. ::: "%ebp");
  1739. return i;
  1740. EOF
  1741. # check wether EBX is available on x86
  1742. check_asm ebx_available '"":::"%ebx"'
  1743. # check whether more than 10 operands are supported
  1744. check_cc <<EOF && enable ten_operands
  1745. int main(void) {
  1746. int x=0;
  1747. __asm__ volatile(
  1748. ""
  1749. :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
  1750. );
  1751. return 0;
  1752. }
  1753. EOF
  1754. # check whether binutils is new enough to compile SSSE3/MMX2
  1755. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1756. enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
  1757. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1758. YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
  1759. enabled x86_64 && append YASMFLAGS "-m amd64"
  1760. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  1761. case "$objformat" in
  1762. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  1763. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  1764. *) append YASMFLAGS "-DPREFIX" ;;
  1765. esac
  1766. disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
  1767. fi
  1768. # check for assembler specific support
  1769. enabled mips && check_asm loongson '"dmult.g $1, $2, $3"'
  1770. enabled ppc && check_asm dcbzl '"dcbzl 0, 1"'
  1771. enabled ppc && check_asm ppc4xx '"maclhw r10, r11, r12"'
  1772. enabled ppc && check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)0)'
  1773. # check for SIMD availability
  1774. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1775. if enabled altivec; then
  1776. check_cflags -maltivec -mabi=altivec &&
  1777. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1778. check_cflags -faltivec
  1779. # check if our compiler supports Motorola AltiVec C API
  1780. check_cc <<EOF || disable altivec
  1781. $inc_altivec_h
  1782. int main(void) {
  1783. vector signed int v1, v2, v3;
  1784. v1 = vec_add(v2,v3);
  1785. return 0;
  1786. }
  1787. EOF
  1788. # check if our compiler supports braces for vector declarations
  1789. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1790. $inc_altivec_h
  1791. int main (void) { (vector int) {1}; return 0; }
  1792. EOF
  1793. fi
  1794. # We have to check if pld is a nop and disable it.
  1795. enabled arm && check_asm pld '"pld [r0]"'
  1796. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1797. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1798. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  1799. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1800. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1801. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1802. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1803. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1804. enabled vis && add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  1805. # ---
  1806. # big/little-endian test
  1807. check_cc <<EOF || die "endian test failed"
  1808. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1809. EOF
  1810. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1811. # ---
  1812. # check availability of some header files
  1813. if check_func dlopen; then
  1814. ldl=
  1815. elif check_func dlopen -ldl; then
  1816. ldl=-ldl
  1817. fi
  1818. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  1819. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  1820. check_func fork
  1821. check_func gethrtime
  1822. check_func getrusage
  1823. check_func inet_aton $network_extralibs
  1824. check_func memalign
  1825. check_func mkstemp
  1826. check_func posix_memalign
  1827. check_func_headers io.h setmode
  1828. check_func_headers lzo/lzo1x.h lzo1x_999_compress
  1829. check_func_headers windows.h GetProcessTimes
  1830. check_func_headers windows.h VirtualAlloc
  1831. check_header conio.h
  1832. check_header dlfcn.h
  1833. check_header malloc.h
  1834. check_header poll.h
  1835. check_header sys/mman.h
  1836. check_header sys/resource.h
  1837. check_header sys/select.h
  1838. check_header termios.h
  1839. check_header vdpau/vdpau.h
  1840. check_header vdpau/vdpau_x11.h
  1841. check_header X11/extensions/XvMClib.h
  1842. if ! enabled_any memalign memalign_hack posix_memalign && enabled need_memalign ; then
  1843. die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
  1844. fi
  1845. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  1846. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  1847. # check for some common methods of building with pthread support
  1848. # do this before the optional library checks as some of them require pthreads
  1849. if enabled pthreads; then
  1850. if check_func pthread_create; then
  1851. :
  1852. elif check_func pthread_create -pthread; then
  1853. add_cflags -pthread
  1854. add_extralibs -pthread
  1855. elif check_func pthread_create -pthreads; then
  1856. add_cflags -pthreads
  1857. add_extralibs -pthreads
  1858. elif check_func pthread_create -lpthreadGC2; then
  1859. add_extralibs -lpthreadGC2
  1860. elif ! check_lib pthread.h pthread_create -lpthread; then
  1861. die "ERROR: can't find pthreads library"
  1862. fi
  1863. fi
  1864. for thread in $THREADS_LIST; do
  1865. if enabled $thread; then
  1866. test -n "$thread_type" &&
  1867. die "ERROR: Only one thread type must be selected." ||
  1868. thread_type="$thread"
  1869. fi
  1870. done
  1871. check_lib math.h sin -lm
  1872. check_lib va/va.h vaInitialize -lva
  1873. # test for C99 functions in math.h
  1874. for func in llrint lrint lrintf round roundf truncf; do
  1875. check_exec <<EOF && enable $func || disable $func
  1876. #include <math.h>
  1877. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1878. EOF
  1879. done
  1880. # these are off by default, so fail if requested and not available
  1881. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1882. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Decoder_Interface_init -lamrnb -lm
  1883. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1884. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  1885. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
  1886. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
  1887. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1888. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1889. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1890. enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
  1891. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1892. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
  1893. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
  1894. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  1895. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  1896. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  1897. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  1898. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1899. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1900. enabled libx264 && require libx264 x264.h x264_encoder_open -lx264 -lm &&
  1901. { check_cpp_condition x264.h "X264_BUILD >= 65" ||
  1902. die "ERROR: libx264 version must be >= 0.65."; }
  1903. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  1904. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1905. # libdc1394 check
  1906. if enabled libdc1394; then
  1907. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1908. enable libdc1394_2; } ||
  1909. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1910. enable libdc1394_1; } ||
  1911. die "ERROR: No version of libdc1394 found "
  1912. fi
  1913. _restrict=
  1914. for restrict_keyword in restrict __restrict__ __restrict; do
  1915. check_cc <<EOF && _restrict=$restrict_keyword && break
  1916. void foo(char * $restrict_keyword p);
  1917. EOF
  1918. done
  1919. ##########################################
  1920. # SDL check
  1921. disable sdl_too_old
  1922. disable sdl
  1923. SDL_CONFIG="${cross_prefix}sdl-config"
  1924. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  1925. sdl_cflags=$("${SDL_CONFIG}" --cflags)
  1926. temp_cflags $sdl_cflags
  1927. temp_extralibs $("${SDL_CONFIG}" --libs)
  1928. if check_lib2 SDL.h SDL_Init; then
  1929. _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
  1930. if test "$_sdlversion" -lt 121 ; then
  1931. enable sdl_too_old
  1932. else
  1933. enable sdl
  1934. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1935. #include <SDL.h>
  1936. int main(int argc, char **argv){
  1937. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1938. int w = vi->current_w;
  1939. return 0;
  1940. }
  1941. EOF
  1942. fi
  1943. fi
  1944. restore_flags
  1945. fi
  1946. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  1947. ##########################################
  1948. # Network check
  1949. if enabled network; then
  1950. check_type "sys/types.h sys/socket.h" socklen_t
  1951. # Prefer arpa/inet.h over winsock2
  1952. if check_header arpa/inet.h ; then
  1953. check_func closesocket
  1954. elif check_header winsock2.h ; then
  1955. network_extralibs="-lws2_32"
  1956. check_type ws2tcpip.h socklen_t
  1957. check_func_headers winsock2.h closesocket
  1958. fi
  1959. fi
  1960. ##########################################
  1961. # IPv6 check
  1962. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1963. #include <sys/types.h>
  1964. #include <sys/socket.h>
  1965. #include <netinet/in.h>
  1966. #include <netdb.h>
  1967. int main(void) {
  1968. struct sockaddr_storage saddr;
  1969. struct ipv6_mreq mreq6;
  1970. getaddrinfo(0,0,0,0);
  1971. getnameinfo(0,0,0,0,0,0,0);
  1972. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1973. }
  1974. EOF
  1975. check_header linux/videodev.h
  1976. check_header linux/videodev2.h
  1977. check_header sys/videoio.h
  1978. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1979. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1980. { check_header dev/bktr/ioctl_meteor.h &&
  1981. check_header dev/bktr/ioctl_bt848.h; } ||
  1982. { check_header machine/ioctl_meteor.h &&
  1983. check_header machine/ioctl_bt848.h; } ||
  1984. { check_header dev/video/meteor/ioctl_meteor.h &&
  1985. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1986. check_header dev/ic/bt8xx.h
  1987. check_header sys/soundcard.h
  1988. check_header soundcard.h
  1989. check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  1990. check_lib2 jack/jack.h jack_client_open -ljack
  1991. # deal with the X11 frame grabber
  1992. enabled x11grab &&
  1993. check_header X11/Xlib.h &&
  1994. check_header X11/extensions/XShm.h &&
  1995. check_func XOpenDisplay -lX11 &&
  1996. check_func XShmCreateImage -lX11 -lXext
  1997. enabled debug && add_cflags -g"$debuglevel"
  1998. # add some useful compiler flags if supported
  1999. check_cflags -Wdeclaration-after-statement
  2000. check_cflags -Wall
  2001. check_cflags -Wno-switch
  2002. check_cflags -Wdisabled-optimization
  2003. check_cflags -Wpointer-arith
  2004. check_cflags -Wredundant-decls
  2005. check_cflags -Wno-pointer-sign
  2006. check_cflags -Wcast-qual
  2007. check_cflags -Wwrite-strings
  2008. check_cflags -Wtype-limits
  2009. check_cflags -Wundef
  2010. enabled extra_warnings && check_cflags -Winline
  2011. # add some linker flags
  2012. check_ldflags -Wl,--warn-common
  2013. check_ldflags -Wl,--as-needed
  2014. 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'
  2015. check_ldflags -Wl,-Bsymbolic
  2016. if enabled small; then
  2017. check_cflags -Os # not all compilers support -Os
  2018. optimizations="small"
  2019. elif enabled optimizations; then
  2020. if enabled xlc; then
  2021. add_cflags -O5
  2022. add_ldflags -O5
  2023. elif enabled ccc; then
  2024. add_cflags -fast
  2025. else
  2026. add_cflags -O3
  2027. fi
  2028. fi
  2029. check_cflags -fno-math-errno
  2030. check_cflags -fno-signed-zeros
  2031. # add some flags for Intel C Compiler
  2032. if enabled icc; then
  2033. # Just warnings, no remarks
  2034. check_cflags -w1
  2035. # -wd: Disable following warnings
  2036. # 144, 167, 556: -Wno-pointer-sign
  2037. # 10006: ignoring unknown option -fno-signed-zeros
  2038. # 10156: ignoring option '-W'; no argument required
  2039. check_cflags -wd144,167,556,10006,10156
  2040. # 11030: Warning unknown option --as-needed
  2041. # 10156: ignoring option '-export'; no argument required
  2042. check_ldflags -wd10156,11030
  2043. # Allow to compile with optimizations
  2044. check_ldflags -march=$cpu
  2045. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  2046. enable ebp_available
  2047. elif enabled ccc; then
  2048. # disable some annoying warnings
  2049. add_cflags -msg_disable cvtu32to64
  2050. add_cflags -msg_disable embedcomment
  2051. add_cflags -msg_disable needconstext
  2052. add_cflags -msg_disable nomainieee
  2053. add_cflags -msg_disable ptrmismatch1
  2054. add_cflags -msg_disable unreachcode
  2055. fi
  2056. # PIC flags for shared library objects where they are needed
  2057. if enabled shared; then
  2058. # LIBOBJFLAGS may have already been set in the OS configuration
  2059. if test -z "$LIBOBJFLAGS" ; then
  2060. case "${subarch-$arch}" in
  2061. x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
  2062. esac
  2063. fi
  2064. fi
  2065. if enabled gprof; then
  2066. add_cflags -p
  2067. add_ldflags -p
  2068. fi
  2069. # Find out if the .align argument is a power of two or not.
  2070. check_asm asmalign_pot '".align 3"'
  2071. enabled_any $DECODER_LIST && enable decoders
  2072. enabled_any $ENCODER_LIST && enable encoders
  2073. enabled_any $HWACCEL_LIST && enable hwaccels
  2074. enabled_any $BSF_LIST && enable bsfs
  2075. enabled_any $DEMUXER_LIST && enable demuxers
  2076. enabled_any $MUXER_LIST && enable muxers
  2077. enabled_any $FILTER_LIST && enable filters
  2078. enabled_any $INDEV_LIST && enable demuxers
  2079. enabled_any $OUTDEV_LIST && enable muxers
  2080. enabled_any $PROTOCOL_LIST && enable protocols
  2081. enabled_any $THREADS_LIST && enable threads
  2082. check_deps $CONFIG_LIST \
  2083. $CONFIG_EXTRA \
  2084. $HAVE_LIST \
  2085. $DECODER_LIST \
  2086. $ENCODER_LIST \
  2087. $HWACCEL_LIST \
  2088. $PARSER_LIST \
  2089. $BSF_LIST \
  2090. $DEMUXER_LIST \
  2091. $MUXER_LIST \
  2092. $FILTER_LIST \
  2093. $INDEV_LIST \
  2094. $OUTDEV_LIST \
  2095. $PROTOCOL_LIST \
  2096. echo "install prefix $prefix"
  2097. echo "source path $source_path"
  2098. echo "C compiler $cc"
  2099. echo ".align is power-of-two $asmalign_pot"
  2100. echo "ARCH $arch ($cpu)"
  2101. if test "$build_suffix" != ""; then
  2102. echo "build suffix $build_suffix"
  2103. fi
  2104. if test "$extra_version" != ""; then
  2105. echo "version string suffix $extra_version"
  2106. fi
  2107. echo "big-endian ${bigendian-no}"
  2108. echo "runtime cpu detection ${runtime_cpudetect-no}"
  2109. if enabled x86; then
  2110. echo "yasm ${yasm-no}"
  2111. echo "MMX enabled ${mmx-no}"
  2112. echo "MMX2 enabled ${mmx2-no}"
  2113. echo "3DNow! enabled ${amd3dnow-no}"
  2114. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2115. echo "SSE enabled ${sse-no}"
  2116. echo "SSSE3 enabled ${ssse3-no}"
  2117. echo "CMOV enabled ${cmov-no}"
  2118. echo "CMOV is fast ${fast_cmov-no}"
  2119. echo "EBX available ${ebx_available-no}"
  2120. echo "EBP available ${ebp_available-no}"
  2121. echo "10 operands supported ${ten_operands-no}"
  2122. fi
  2123. if enabled arm; then
  2124. echo "ARMv5TE enabled ${armv5te-no}"
  2125. echo "ARMv6 enabled ${armv6-no}"
  2126. echo "ARMv6T2 enabled ${armv6t2-no}"
  2127. echo "ARM VFP enabled ${armvfp-no}"
  2128. echo "IWMMXT enabled ${iwmmxt-no}"
  2129. echo "NEON enabled ${neon-no}"
  2130. fi
  2131. if enabled mips; then
  2132. echo "MMI enabled ${mmi-no}"
  2133. fi
  2134. if enabled ppc; then
  2135. echo "AltiVec enabled ${altivec-no}"
  2136. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2137. echo "dcbzl available ${dcbzl-no}"
  2138. echo "performance report ${powerpc_perf-no}"
  2139. fi
  2140. if enabled sparc; then
  2141. echo "VIS enabled ${vis-no}"
  2142. fi
  2143. echo "gprof enabled ${gprof-no}"
  2144. echo "debug symbols ${debug-no}"
  2145. echo "strip symbols ${stripping-no}"
  2146. echo "optimizations ${optimizations-no}"
  2147. echo "static ${static-no}"
  2148. echo "shared ${shared-no}"
  2149. echo "postprocessing support ${postproc-no}"
  2150. echo "new filter support ${avfilter-no}"
  2151. echo "filters using lavformat ${avfilter_lavf-no}"
  2152. echo "network support ${network-no}"
  2153. if enabled network; then
  2154. echo "IPv6 support ${ipv6-no}"
  2155. fi
  2156. echo "threading support ${thread_type-no}"
  2157. echo "SDL support ${sdl-no}"
  2158. if enabled sdl_too_old; then
  2159. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  2160. fi
  2161. echo "Sun medialib support ${mlib-no}"
  2162. echo "AVISynth enabled ${avisynth-no}"
  2163. echo "libamr-nb support ${libamr_nb-no}"
  2164. echo "libamr-wb support ${libamr_wb-no}"
  2165. echo "libdc1394 support ${libdc1394-no}"
  2166. echo "libdirac enabled ${libdirac-no}"
  2167. echo "libfaac enabled ${libfaac-no}"
  2168. echo "libfaad enabled ${libfaad-no}"
  2169. echo "libfaad dlopened ${libfaadbin-no}"
  2170. echo "libgsm enabled ${libgsm-no}"
  2171. echo "libmp3lame enabled ${libmp3lame-no}"
  2172. echo "libnut enabled ${libnut-no}"
  2173. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  2174. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  2175. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2176. echo "libschroedinger enabled ${libschroedinger-no}"
  2177. echo "libspeex enabled ${libspeex-no}"
  2178. echo "libtheora enabled ${libtheora-no}"
  2179. echo "libvorbis enabled ${libvorbis-no}"
  2180. echo "libx264 enabled ${libx264-no}"
  2181. echo "libxvid enabled ${libxvid-no}"
  2182. echo "zlib enabled ${zlib-no}"
  2183. echo "bzlib enabled ${bzlib-no}"
  2184. echo
  2185. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  2186. echo "Enabled ${type}s:"
  2187. eval list=\$$(toupper $type)_LIST
  2188. for part in $list; do
  2189. enabled $part && echo ${part%_*}
  2190. done | sort | pr -3 -t
  2191. echo
  2192. done
  2193. license="LGPL version 2.1 or later"
  2194. if enabled nonfree; then
  2195. license="nonfree and unredistributable"
  2196. elif enabled gplv3; then
  2197. license="GPL version 3 or later"
  2198. elif enabled lgplv3; then
  2199. license="LGPL version 3 or later"
  2200. elif enabled gpl; then
  2201. license="GPL version 2 or later"
  2202. fi
  2203. echo "License: $license"
  2204. echo "Creating config.mak and config.h..."
  2205. echo "# Automatically generated by configure - do not modify!" > config.mak
  2206. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  2207. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  2208. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  2209. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  2210. echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
  2211. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  2212. echo "prefix=$prefix" >> config.mak
  2213. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  2214. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  2215. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  2216. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  2217. echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
  2218. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  2219. echo "SRC_PATH=\"$source_path\"" >> config.mak
  2220. echo "SRC_PATH_BARE=$source_path" >> config.mak
  2221. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  2222. echo "CC=$cc" >> config.mak
  2223. echo "AS=$as" >> config.mak
  2224. echo "YASM=$yasmexe" >> config.mak
  2225. echo "AR=$ar" >> config.mak
  2226. echo "RANLIB=$ranlib" >> config.mak
  2227. echo "LN_S=$ln_s" >> config.mak
  2228. enabled stripping &&
  2229. echo "STRIP=$strip" >> config.mak ||
  2230. echo "STRIP=echo ignoring strip" >> config.mak
  2231. echo "OPTFLAGS=$CFLAGS" >> config.mak
  2232. echo "LDFLAGS=$LDFLAGS" >> config.mak
  2233. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  2234. echo "SHFLAGS=$SHFLAGS" >> config.mak
  2235. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  2236. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  2237. echo "BUILD_STATIC=$static" >> config.mak
  2238. echo "BUILDSUF=$build_suffix" >> config.mak
  2239. echo "FULLNAME=$FULLNAME" >> config.mak
  2240. echo "LIBPREF=$LIBPREF" >> config.mak
  2241. echo "LIBSUF=$LIBSUF" >> config.mak
  2242. echo "LIBNAME=$LIBNAME" >> config.mak
  2243. echo "SLIBPREF=$SLIBPREF" >> config.mak
  2244. echo "SLIBSUF=$SLIBSUF" >> config.mak
  2245. echo "EXESUF=$EXESUF" >> config.mak
  2246. echo "EXTRA_VERSION=$extra_version" >> config.mak
  2247. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  2248. echo "HOSTCC=$host_cc" >> config.mak
  2249. echo "HOSTCFLAGS=$host_cflags" >> config.mak
  2250. echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
  2251. echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
  2252. echo "HOSTLIBS=$host_libs" >> config.mak
  2253. echo "TARGET_EXEC=$target_exec" >> config.mak
  2254. echo "TARGET_PATH=$target_path" >> config.mak
  2255. if enabled bigendian; then
  2256. echo "WORDS_BIGENDIAN=yes" >> config.mak
  2257. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  2258. fi
  2259. if enabled sdl; then
  2260. echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
  2261. echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
  2262. fi
  2263. if enabled texi2html; then
  2264. echo "BUILD_DOC=yes" >> config.mak
  2265. fi
  2266. get_version(){
  2267. name=$1
  2268. file=$source_path/$2
  2269. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2270. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2271. lcname=$(tolower $name)
  2272. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2273. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2274. }
  2275. get_version LIBSWSCALE libswscale/swscale.h
  2276. get_version LIBPOSTPROC libpostproc/postprocess.h
  2277. get_version LIBAVCODEC libavcodec/avcodec.h
  2278. get_version LIBAVDEVICE libavdevice/avdevice.h
  2279. get_version LIBAVFORMAT libavformat/avformat.h
  2280. get_version LIBAVUTIL libavutil/avutil.h
  2281. get_version LIBAVFILTER libavfilter/avfilter.h
  2282. if enabled shared; then
  2283. echo "BUILD_SHARED=yes" >> config.mak
  2284. echo "PIC=-fPIC -DPIC" >> config.mak
  2285. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  2286. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  2287. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  2288. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  2289. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  2290. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  2291. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  2292. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  2293. fi
  2294. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  2295. echo "EXTRALIBS=$extralibs" >> config.mak
  2296. echo "ARCH=$arch" >> config.mak
  2297. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2298. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2299. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2300. $CONFIG_EXTRA \
  2301. $DECODER_LIST \
  2302. $ENCODER_LIST \
  2303. $HWACCEL_LIST \
  2304. $PARSER_LIST \
  2305. $BSF_LIST \
  2306. $DEMUXER_LIST \
  2307. $MUXER_LIST \
  2308. $FILTER_LIST \
  2309. $PROTOCOL_LIST \
  2310. $INDEV_LIST \
  2311. $OUTDEV_LIST \
  2312. echo "#define restrict $_restrict" >> $TMPH
  2313. if enabled small; then
  2314. echo "#define av_always_inline" >> $TMPH
  2315. fi
  2316. # Apparently it's not possible to portably echo a backslash.
  2317. enabled asmalign_pot &&
  2318. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  2319. printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
  2320. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  2321. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2322. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2323. cmp -s $TMPH config.h &&
  2324. echo "config.h is unchanged" ||
  2325. mv -f $TMPH config.h
  2326. # build tree in object directory if source path is different from current one
  2327. if enabled source_path_used; then
  2328. DIRS="\
  2329. doc \
  2330. libavcodec \
  2331. libavcodec/alpha \
  2332. libavcodec/arm \
  2333. libavcodec/bfin \
  2334. libavcodec/mlib \
  2335. libavcodec/ppc \
  2336. libavcodec/sh4 \
  2337. libavcodec/sparc \
  2338. libavcodec/x86 \
  2339. libavdevice \
  2340. libavfilter \
  2341. libavformat \
  2342. libavutil \
  2343. libpostproc \
  2344. libswscale \
  2345. libswscale/bfin \
  2346. libswscale/mlib \
  2347. libswscale/ppc \
  2348. libswscale/sparc \
  2349. libswscale/x86 \
  2350. tests \
  2351. tools \
  2352. "
  2353. FILES="\
  2354. Makefile \
  2355. common.mak \
  2356. subdir.mak \
  2357. doc/texi2pod.pl \
  2358. libavcodec/Makefile \
  2359. libavdevice/Makefile \
  2360. libavfilter/Makefile \
  2361. libavformat/Makefile \
  2362. libavutil/Makefile \
  2363. libpostproc/Makefile \
  2364. libswscale/Makefile \
  2365. "
  2366. for dir in $DIRS ; do
  2367. mkdir -p $dir
  2368. done
  2369. for f in $FILES ; do
  2370. $ln_s "$source_path/$f" $f
  2371. done
  2372. fi
  2373. # build pkg-config files
  2374. pkgconfig_generate(){
  2375. name=$1
  2376. shortname=${name#lib}${build_suffix}
  2377. comment=$2
  2378. version=$3
  2379. libs=$4
  2380. requires=$5
  2381. cat <<EOF > $name/$name.pc
  2382. prefix=$prefix
  2383. exec_prefix=\${prefix}
  2384. libdir=$libdir
  2385. includedir=$incdir
  2386. Name: $name
  2387. Description: $comment
  2388. Version: $version
  2389. Requires: $(disabled shared && echo $requires)
  2390. Requires.private: $(enabled shared && echo $requires)
  2391. Conflicts:
  2392. Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
  2393. Libs.private: $(enabled shared && echo $libs)
  2394. Cflags: -I\${includedir}
  2395. EOF
  2396. cat <<EOF > $name/$name-uninstalled.pc
  2397. prefix=
  2398. exec_prefix=
  2399. libdir=\${pcfiledir}
  2400. includedir=${source_path}
  2401. Name: $name
  2402. Description: $comment
  2403. Version: $version
  2404. Requires: $requires
  2405. Conflicts:
  2406. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2407. Cflags: -I\${includedir}
  2408. EOF
  2409. }
  2410. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2411. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2412. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  2413. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  2414. enabled avfilter &&
  2415. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2416. enabled postproc &&
  2417. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2418. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"