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.

2617 lines
75KB

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