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.

2558 lines
73KB

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