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.

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