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.

2569 lines
74KB

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