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.

2624 lines
76KB

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