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.

2613 lines
75KB

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