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.

2393 lines
69KB

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