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.

2646 lines
77KB

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