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.

2388 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. dca_decoder_select="fft mdct"
  844. dxa_decoder_deps="zlib"
  845. eac3_decoder_deps="gpl"
  846. eac3_decoder_select="fft mdct"
  847. ffv1_decoder_select="golomb"
  848. flac_decoder_select="golomb"
  849. flac_encoder_select="golomb"
  850. flashsv_decoder_deps="zlib"
  851. flashsv_encoder_deps="zlib"
  852. h264_decoder_select="golomb"
  853. imc_decoder_select="fft mdct"
  854. jpegls_decoder_select="golomb"
  855. jpegls_encoder_select="golomb"
  856. loco_decoder_select="golomb"
  857. mpeg_xvmc_decoder_deps="xvmc"
  858. nellymoser_decoder_select="fft mdct"
  859. nellymoser_encoder_select="fft mdct"
  860. png_decoder_deps="zlib"
  861. png_encoder_deps="zlib"
  862. qdm2_decoder_select="fft mdct"
  863. shorten_decoder_select="golomb"
  864. sonic_decoder_select="golomb"
  865. sonic_encoder_select="golomb"
  866. sonic_ls_encoder_select="golomb"
  867. svq3_decoder_select="golomb"
  868. vorbis_decoder_select="fft mdct"
  869. vorbis_encoder_select="fft mdct"
  870. wmav1_decoder_select="fft mdct"
  871. wmav1_encoder_select="fft mdct"
  872. wmav2_decoder_select="fft mdct"
  873. wmav2_encoder_select="fft mdct"
  874. zmbv_decoder_deps="zlib"
  875. zmbv_encoder_deps="zlib"
  876. # external libraries
  877. libamr_nb_decoder_deps="libamr_nb"
  878. libamr_nb_encoder_deps="libamr_nb"
  879. libamr_wb_decoder_deps="libamr_wb"
  880. libamr_wb_encoder_deps="libamr_wb"
  881. libdirac_decoder_deps="libdirac !libschroedinger"
  882. libdirac_encoder_deps="libdirac"
  883. libfaac_encoder_deps="libfaac"
  884. libfaad_decoder_deps="libfaad"
  885. libfaadbin_decoder_extralibs='$ldl'
  886. libgsm_decoder_deps="libgsm"
  887. libgsm_encoder_deps="libgsm"
  888. libgsm_ms_decoder_deps="libgsm"
  889. libgsm_ms_encoder_deps="libgsm"
  890. libmp3lame_encoder_deps="libmp3lame"
  891. libschroedinger_decoder_deps="libschroedinger"
  892. libschroedinger_encoder_deps="libschroedinger"
  893. libspeex_decoder_deps="libspeex"
  894. libtheora_encoder_deps="libtheora"
  895. libvorbis_encoder_deps="libvorbis"
  896. libx264_encoder_deps="libx264"
  897. libxvid_encoder_deps="libxvid"
  898. mpeg4aac_decoder_deps="libfaad"
  899. # demuxers / muxers
  900. ac3_demuxer_deps="ac3_parser"
  901. audio_beos_demuxer_deps="audio_beos"
  902. audio_beos_demuxer_extralibs="-lmedia -lbe"
  903. audio_beos_muxer_deps="audio_beos"
  904. audio_beos_muxer_extralibs="-lmedia -lbe"
  905. avisynth_demuxer_deps="avisynth"
  906. bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  907. dirac_demuxer_deps="dirac_parser"
  908. dv1394_demuxer_deps="dv1394 dv_demuxer"
  909. libdc1394_demuxer_deps="libdc1394"
  910. libnut_demuxer_deps="libnut"
  911. libnut_muxer_deps="libnut"
  912. mp3_demuxer_deps="mpegaudio_parser"
  913. oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
  914. oss_muxer_deps_any="soundcard_h sys_soundcard_h"
  915. redir_demuxer_deps="network"
  916. rtp_muxer_deps="network rtp_protocol"
  917. rtsp_demuxer_deps="sdp_demuxer"
  918. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  919. v4l_demuxer_deps="linux_videodev_h"
  920. v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
  921. vfwcap_demuxer_deps="capCreateCaptureWindow"
  922. vfwcap_demuxer_extralibs="-lvfw32"
  923. x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
  924. x11_grab_device_demuxer_extralibs="-lX11 -lXext"
  925. # protocols
  926. http_protocol_deps="network"
  927. rtp_protocol_deps="udp_protocol"
  928. tcp_protocol_deps="network"
  929. udp_protocol_deps="network"
  930. # filters
  931. movie_filter_deps="avfilter_lavf"
  932. # programs
  933. ffplay_deps="sdl"
  934. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  935. ffserver_extralibs='$ldl'
  936. vhook_extralibs='$ldl'
  937. # default parameters
  938. logfile="config.err"
  939. # installation paths
  940. prefix_default="/usr/local"
  941. bindir_default='${prefix}/bin'
  942. incdir_default='${prefix}/include'
  943. libdir_default='${prefix}/lib'
  944. mandir_default='${prefix}/share/man'
  945. shlibdir_default="$libdir_default"
  946. # toolchain
  947. cc_default="gcc"
  948. yasmexe="yasm"
  949. ar="ar"
  950. nm="nm"
  951. ranlib="ranlib"
  952. strip="strip"
  953. asmalign_pot="unknown"
  954. ln_s="ln -sf"
  955. objformat="elf"
  956. # machine
  957. arch=`uname -m`
  958. cpu="generic"
  959. # OS
  960. target_os=$(tolower $(uname -s))
  961. # libraries
  962. enable bzlib
  963. enable zlib
  964. # configurable options
  965. enable debug
  966. enable ffmpeg
  967. enable ffplay
  968. enable ffserver
  969. enable ipv6
  970. enable mpegaudio_hp
  971. enable network
  972. enable optimizations
  973. enable protocols
  974. enable static
  975. enable stripping
  976. vhook="default"
  977. # build settings
  978. add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  979. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  980. VHOOKSHFLAGS='$(SHFLAGS)'
  981. FFSERVERLDFLAGS=-Wl,-E
  982. LIBPREF="lib"
  983. LIBSUF=".a"
  984. FULLNAME='$(NAME)$(BUILDSUF)'
  985. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  986. SLIBPREF="lib"
  987. SLIBSUF=".so"
  988. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  989. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  990. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  991. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  992. # gcc stupidly only outputs the basename of targets with -MM, but we need the
  993. # full relative path for objects in subdirectories for non-recursive Make.
  994. 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,"'
  995. # find source path
  996. source_path="`dirname \"$0\"`"
  997. enable source_path_used
  998. if test -z "$source_path" -o "$source_path" = "." ; then
  999. source_path="`pwd`"
  1000. disable source_path_used
  1001. else
  1002. source_path="`cd \"$source_path\"; pwd`"
  1003. echo "$source_path" | grep -q '[[:blank:]]' &&
  1004. die "Out of tree builds are impossible with whitespace in source path."
  1005. fi
  1006. FFMPEG_CONFIGURATION="$@"
  1007. find_things(){
  1008. thing=$1
  1009. pattern=$2
  1010. file=$source_path/$3
  1011. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1012. }
  1013. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1014. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1015. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1016. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1017. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1018. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1019. OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
  1020. INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
  1021. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1022. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1023. enable $ARCH_EXT_LIST \
  1024. $DECODER_LIST \
  1025. $ENCODER_LIST \
  1026. $PARSER_LIST \
  1027. $BSF_LIST \
  1028. $DEMUXER_LIST \
  1029. $MUXER_LIST \
  1030. $FILTER_LIST \
  1031. $PROTOCOL_LIST \
  1032. $INDEV_LIST \
  1033. $OUTDEV_LIST \
  1034. die_unknown(){
  1035. echo "Unknown option \"$1\"."
  1036. echo "See $0 --help for available options."
  1037. exit 1
  1038. }
  1039. show_list() {
  1040. suffix=_$1
  1041. shift
  1042. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  1043. exit 0
  1044. }
  1045. for opt do
  1046. optval="${opt#*=}"
  1047. case "$opt" in
  1048. --extra-cflags=*) add_cflags "$optval"
  1049. ;;
  1050. --extra-ldflags=*) add_ldflags "$optval"
  1051. ;;
  1052. --extra-libs=*) add_extralibs "$optval"
  1053. ;;
  1054. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1055. ;;
  1056. --enable-debug=*) debuglevel="$optval"
  1057. ;;
  1058. --enable-*=*|--disable-*=*)
  1059. eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
  1060. case "$thing" in
  1061. encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
  1062. *) die_unknown "$opt" ;;
  1063. esac
  1064. ;;
  1065. --enable-?*|--disable-?*)
  1066. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  1067. if is_in $option $COMPONENT_LIST; then
  1068. eval $action \$$(toupper ${option%s})_LIST
  1069. elif is_in $option $CMDLINE_SELECT; then
  1070. $action $option
  1071. else
  1072. die_unknown $opt
  1073. fi
  1074. ;;
  1075. --list-*)
  1076. NAME="${opt#--list-}"
  1077. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1078. NAME=${NAME%s}
  1079. eval show_list $NAME \$$(toupper $NAME)_LIST
  1080. ;;
  1081. --help|-h) show_help
  1082. ;;
  1083. *)
  1084. optname="${opt%%=*}"
  1085. optname="${optname#--}"
  1086. optname=$(echo "$optname" | sed 's/-/_/g')
  1087. is_in $optname $CMDLINE_SET || die_unknown $opt
  1088. eval $optname='$optval'
  1089. ;;
  1090. esac
  1091. done
  1092. disabled logging && logfile=/dev/null
  1093. echo "# $0 $@" > $logfile
  1094. set >> $logfile
  1095. cc_default="${cross_prefix}${cc_default}"
  1096. yasmexe="${cross_prefix}${yasmexe}"
  1097. ar="${cross_prefix}${ar}"
  1098. nm="${cross_prefix}${nm}"
  1099. ranlib="${cross_prefix}${ranlib}"
  1100. strip="${cross_prefix}${strip}"
  1101. set_default cc
  1102. # set temporary file name
  1103. if test ! -z "$TMPDIR" ; then
  1104. TMPDIR1="${TMPDIR}"
  1105. elif test ! -z "$TEMPDIR" ; then
  1106. TMPDIR1="${TEMPDIR}"
  1107. else
  1108. TMPDIR1="/tmp"
  1109. fi
  1110. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  1111. TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
  1112. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  1113. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  1114. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  1115. TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
  1116. check_cflags -std=c99
  1117. case "$arch" in
  1118. i386|i486|i586|i686|i86pc|BePC)
  1119. arch="x86_32"
  1120. enable fast_unaligned
  1121. ;;
  1122. x86_64|amd64)
  1123. arch="x86_32"
  1124. enable fast_unaligned
  1125. check_cc <<EOF && enable fast_64bit && arch="x86_64"
  1126. int test[sizeof(char*) - 7];
  1127. EOF
  1128. ;;
  1129. # armv4l is a subset of armv[567]*l
  1130. arm|armv[4567]*l)
  1131. arch="armv4l"
  1132. ;;
  1133. alpha)
  1134. arch="alpha"
  1135. enable fast_64bit
  1136. ;;
  1137. "Power Macintosh"|ppc|powerpc)
  1138. arch="powerpc"
  1139. enable fast_unaligned
  1140. ;;
  1141. ppc64)
  1142. arch="powerpc"
  1143. enable fast_64bit
  1144. enable fast_unaligned
  1145. ;;
  1146. mips|mipsel|IP*)
  1147. arch="mips"
  1148. ;;
  1149. sun4u|sparc64)
  1150. arch="sparc64"
  1151. enable fast_64bit
  1152. ;;
  1153. sparc)
  1154. arch="sparc"
  1155. ;;
  1156. sh4)
  1157. arch="sh4"
  1158. ;;
  1159. parisc)
  1160. arch="parisc"
  1161. ;;
  1162. parisc64)
  1163. arch="parisc"
  1164. enable fast_64bit
  1165. ;;
  1166. s390|s390x)
  1167. arch="s390"
  1168. ;;
  1169. m68k)
  1170. arch="m68k"
  1171. ;;
  1172. ia64)
  1173. arch="ia64"
  1174. enable fast_64bit
  1175. ;;
  1176. bfin)
  1177. arch="bfin"
  1178. ;;
  1179. *)
  1180. arch="unknown"
  1181. ;;
  1182. esac
  1183. enable $arch
  1184. enabled_any x86_32 x86_64 && enable x86
  1185. enabled sparc64 && enable sparc
  1186. # OS specific
  1187. case $target_os in
  1188. beos|haiku|zeta)
  1189. prefix_default="$HOME/config"
  1190. # helps building libavcodec
  1191. add_cflags "-DPIC -fomit-frame-pointer"
  1192. # 3 gcc releases known for BeOS, each with ugly bugs
  1193. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1194. case "$gcc_version" in
  1195. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1196. disable mmx
  1197. ;;
  1198. *20010315*) echo "BeBits gcc"
  1199. add_cflags "-fno-expensive-optimizations"
  1200. ;;
  1201. esac
  1202. SHFLAGS=-nostart
  1203. # enable BeOS things
  1204. enable audio_beos
  1205. # no need for libm, but the inet stuff
  1206. # Check for BONE
  1207. # XXX: actually should check for NOT net_server
  1208. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  1209. network_extralibs="-lbind -lsocket"
  1210. else
  1211. enable beos_netserver
  1212. network_extralibs="-lnet"
  1213. fi ;;
  1214. sunos)
  1215. FFSERVERLDFLAGS=""
  1216. SHFLAGS='-shared -Wl,-h,$$(@F)'
  1217. network_extralibs="-lsocket -lnsl"
  1218. ;;
  1219. netbsd)
  1220. oss_demuxer_extralibs="-lossaudio"
  1221. oss_muxer_extralibs="-lossaudio"
  1222. ;;
  1223. openbsd)
  1224. disable need_memalign
  1225. LIBOBJFLAGS='$(PIC)'
  1226. SHFLAGS='-shared'
  1227. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
  1228. SLIBNAME_WITH_VERSION='$(SLIBNAME)'
  1229. SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
  1230. oss_demuxer_extralibs="-lossaudio"
  1231. oss_muxer_extralibs="-lossaudio"
  1232. ;;
  1233. freebsd)
  1234. disable need_memalign
  1235. ;;
  1236. bsd/os)
  1237. osextralibs="-lpoll -lgnugetopt"
  1238. strip="strip -d"
  1239. ;;
  1240. darwin)
  1241. disable need_memalign
  1242. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1243. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
  1244. strip="strip -x"
  1245. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1246. SLIBSUF=".dylib"
  1247. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1248. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1249. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1250. objformat="macho"
  1251. enabled x86_64 && objformat="macho64"
  1252. ;;
  1253. mingw32*)
  1254. target_os=mingw32
  1255. LIBTARGET=i386
  1256. if test $arch = x86_64; then
  1257. disable need_memalign
  1258. LIBTARGET=x64
  1259. fi
  1260. shlibdir_default="$bindir_default"
  1261. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1262. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1263. if enabled swscale; then
  1264. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1265. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1266. fi
  1267. disable ffserver
  1268. SLIBPREF=""
  1269. SLIBSUF=".dll"
  1270. EXESUF=".exe"
  1271. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1272. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1273. SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1274. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1275. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
  1276. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1277. SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  1278. objformat="win32"
  1279. enable dos_paths
  1280. ;;
  1281. cygwin*)
  1282. target_os=cygwin
  1283. shlibdir_default="$bindir_default"
  1284. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1285. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1286. if enabled swscale; then
  1287. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1288. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1289. fi
  1290. EXESUF=".exe"
  1291. SLIBPREF="cyg"
  1292. SLIBSUF=".dll"
  1293. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1294. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1295. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1296. objformat="win32"
  1297. enable dos_paths
  1298. ;;
  1299. *-dos|freedos|opendos)
  1300. disable ffplay ffserver vhook
  1301. disable $INDEV_LIST $OUTDEV_LIST
  1302. network_extralibs="-lsocket"
  1303. EXESUF=".exe"
  1304. objformat="win32"
  1305. enable dos_paths
  1306. ;;
  1307. linux)
  1308. enable dv1394
  1309. ;;
  1310. irix*)
  1311. target_os=irix
  1312. ranlib="echo ignoring ranlib"
  1313. ;;
  1314. os/2*)
  1315. strip="lxlite"
  1316. ln_s="cp -f"
  1317. EXESUF=".exe"
  1318. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1319. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1320. FFSERVERLDFLAGS=""
  1321. LIBSUF="_s.a"
  1322. SLIBPREF=""
  1323. SLIBSUF=".dll"
  1324. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1325. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1326. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1327. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1328. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1329. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1330. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1331. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1332. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1333. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1334. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1335. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1336. disable vhook
  1337. enable dos_paths
  1338. ;;
  1339. interix)
  1340. disable vhook
  1341. ;;
  1342. *)
  1343. target_os="${target_os}-UNKNOWN"
  1344. ;;
  1345. esac
  1346. set_default $PATHS_LIST
  1347. add_extralibs $osextralibs
  1348. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1349. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1350. test -n "$cross_prefix" && enable cross_compile
  1351. # we need to build at least one lib type
  1352. if ! enabled_any static shared; then
  1353. cat <<EOF
  1354. At least one library type must be built.
  1355. Specify --enable-static to build the static libraries or --enable-shared to
  1356. build the shared libraries as well. To only build the shared libraries specify
  1357. --disable-static in addition to --enable-shared.
  1358. EOF
  1359. exit 1;
  1360. fi
  1361. disabled static && LIBNAME=""
  1362. if enabled_any libfaad libfaadbin ; then
  1363. if check_header faad.h; then
  1364. check_cc <<EOF
  1365. #include <faad.h>
  1366. #ifndef FAAD2_VERSION
  1367. ok faad1
  1368. #endif
  1369. int main(void) { return 0; }
  1370. EOF
  1371. test $? = 0 && enable libfaad2
  1372. else
  1373. die "FAAD test failed."
  1374. fi
  1375. fi
  1376. if ! enabled gpl; then
  1377. die_gpl_disabled(){
  1378. name=$1
  1379. shift
  1380. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1381. }
  1382. die_gpl_disabled "The Postprocessing code" postproc
  1383. die_gpl_disabled "libx264" libx264
  1384. die_gpl_disabled "libxvidcore" libxvid
  1385. die_gpl_disabled "FAAD2" libfaad2
  1386. die_gpl_disabled "The X11 grabber" x11grab
  1387. die_gpl_disabled "The software scaler" swscale
  1388. fi
  1389. if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
  1390. die "libamr is nonfree and --enable-nonfree is not specified."
  1391. fi
  1392. check_deps $ARCH_EXT_LIST
  1393. test -z "$need_memalign" && need_memalign="$mmx"
  1394. #Darwin CC versions
  1395. if test $target_os = darwin; then
  1396. if $cc -v 2>&1 | grep -q xlc; then
  1397. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1398. else
  1399. add_cflags "-pipe"
  1400. check_cflags "-force_cpusubtype_ALL"
  1401. check_cflags "-Wno-sign-compare"
  1402. enabled shared || check_cflags -mdynamic-no-pic
  1403. fi
  1404. fi
  1405. disabled optimizations || check_cflags -fomit-frame-pointer
  1406. # Add processor-specific flags
  1407. if test $cpu != "generic"; then
  1408. warn_altivec(){
  1409. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1410. }
  1411. case $cpu in
  1412. 601|ppc601|PowerPC601)
  1413. add_cflags "-mcpu=601"
  1414. warn_altivec enabled PPC601
  1415. ;;
  1416. 603*|ppc603*|PowerPC603*)
  1417. add_cflags "-mcpu=603"
  1418. warn_altivec enabled PPC603
  1419. ;;
  1420. 604*|ppc604*|PowerPC604*)
  1421. add_cflags "-mcpu=604"
  1422. warn_altivec enabled PPC604
  1423. ;;
  1424. G3|g3|75*|ppc75*|PowerPC75*)
  1425. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1426. warn_altivec enabled PPC75x
  1427. ;;
  1428. G4|g4|745*|ppc745*|PowerPC745*)
  1429. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1430. warn_altivec disabled PPC745x
  1431. ;;
  1432. 74*|ppc74*|PowerPC74*)
  1433. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1434. warn_altivec disabled PPC74xx
  1435. ;;
  1436. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1437. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1438. warn_altivec disabled PPC970
  1439. enable ppc64
  1440. ;;
  1441. Cell|CELL|cell)
  1442. add_cflags "-mcpu=cell"
  1443. warn_altivec disabled Cell
  1444. enable ppc64
  1445. ;;
  1446. # targets that do NOT support conditional mov (cmov)
  1447. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1448. add_cflags "-march=$cpu"
  1449. disable cmov
  1450. ;;
  1451. # targets that do support conditional mov (cmov)
  1452. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1453. add_cflags "-march=$cpu"
  1454. enable cmov
  1455. enable fast_cmov
  1456. ;;
  1457. # targets that do support conditional mov but on which it's slow
  1458. pentium4|pentium4m|prescott|nocona)
  1459. add_cflags "-march=$cpu"
  1460. enable cmov
  1461. disable fast_cmov
  1462. ;;
  1463. sparc64)
  1464. add_cflags "-mcpu=v9"
  1465. ;;
  1466. arm11*|cortex*)
  1467. add_cflags "-mcpu=$cpu"
  1468. enable fast_unaligned
  1469. ;;
  1470. armv*)
  1471. add_cflags "-march=$cpu"
  1472. ;;
  1473. arm*)
  1474. add_cflags "-mcpu=$cpu"
  1475. ;;
  1476. *)
  1477. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1478. ;;
  1479. esac
  1480. fi
  1481. # make sure we can execute files in $TMPDIR
  1482. cat > $TMPSH 2>> $logfile <<EOF
  1483. #! /bin/sh
  1484. EOF
  1485. chmod +x $TMPSH >> $logfile 2>&1
  1486. if ! $TMPSH >> $logfile 2>&1; then
  1487. cat <<EOF
  1488. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1489. variable to another directory and make sure that $TMPDIR1 is not mounted
  1490. noexec.
  1491. EOF
  1492. die "Sanity test failed."
  1493. fi
  1494. rm $TMPSH
  1495. # compiler sanity check
  1496. check_exec <<EOF
  1497. int main(void){ return 0; }
  1498. EOF
  1499. if test "$?" != 0; then
  1500. echo "$cc is unable to create an executable file."
  1501. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1502. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1503. echo "Only do this if you know what cross compiling means."
  1504. fi
  1505. die "C compiler test failed."
  1506. fi
  1507. check_cc <<EOF || die "Symbol mangling check failed."
  1508. int ff_extern;
  1509. EOF
  1510. sym=$($nm -P -g $TMPO | grep ff_extern)
  1511. extern_prefix=${sym%%ff_extern*}
  1512. check_asm inline_asm '""'
  1513. if enabled x86; then
  1514. # check whether EBP is available on x86
  1515. # As 'i' is stored on the stack, this program will crash
  1516. # if the base pointer is used to access it because the
  1517. # base pointer is cleared in the inline assembly code.
  1518. check_exec_crash <<EOF && enable ebp_available
  1519. volatile int i=0;
  1520. __asm__ volatile (
  1521. "xorl %%ebp, %%ebp"
  1522. ::: "%ebp");
  1523. return i;
  1524. EOF
  1525. # check wether EBX is available on x86
  1526. check_asm ebx_available '"":::"%ebx"'
  1527. # check whether binutils is new enough to compile SSSE3/MMX2
  1528. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1529. enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
  1530. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1531. YASMFLAGS="-f $objformat -DARCH_$(toupper $arch)"
  1532. enabled x86_64 && append YASMFLAGS "-m amd64"
  1533. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  1534. case "$objformat" in
  1535. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  1536. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  1537. *) append YASMFLAGS "-DPREFIX" ;;
  1538. esac
  1539. check_yasm "pabsw xmm0, xmm0" && enable yasm
  1540. fi
  1541. # check for assembler specific support
  1542. if test $arch = "powerpc"; then
  1543. check_asm dcbzl '"dcbzl 0, 1"'
  1544. fi
  1545. # check for SIMD availability
  1546. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1547. if enabled altivec; then
  1548. check_cflags -maltivec -mabi=altivec &&
  1549. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1550. check_cflags -faltivec
  1551. # check if our compiler supports Motorola AltiVec C API
  1552. check_cc <<EOF || disable altivec
  1553. $inc_altivec_h
  1554. int main(void) {
  1555. vector signed int v1, v2, v3;
  1556. v1 = vec_add(v2,v3);
  1557. return 0;
  1558. }
  1559. EOF
  1560. # check if our compiler supports braces for vector declarations
  1561. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1562. $inc_altivec_h
  1563. int main (void) { (vector int) {1}; return 0; }
  1564. EOF
  1565. fi
  1566. # We have to check if pld is a nop and disable it.
  1567. enabled armv4l && check_asm pld '"pld [r0]"'
  1568. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1569. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1570. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1571. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1572. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1573. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1574. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1575. enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
  1576. # ---
  1577. # big/little-endian test
  1578. check_cc <<EOF || die "endian test failed"
  1579. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1580. EOF
  1581. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1582. # ---
  1583. # check availability of some header files
  1584. if check_func dlopen; then
  1585. ldl=
  1586. elif check_func dlopen -ldl; then
  1587. ldl=-ldl
  1588. fi
  1589. check_func fork
  1590. check_func gethrtime
  1591. check_func getrusage
  1592. check_func inet_aton $network_extralibs
  1593. check_func memalign
  1594. check_func mkstemp
  1595. check_func_headers windows.h GetProcessTimes
  1596. check_header conio.h
  1597. check_header dlfcn.h
  1598. check_header malloc.h
  1599. check_header poll.h
  1600. check_header sys/mman.h
  1601. check_header sys/resource.h
  1602. check_header sys/select.h
  1603. check_header termios.h
  1604. if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
  1605. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1606. fi
  1607. enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
  1608. enabled bzlib && check_lib bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  1609. # check for some common methods of building with pthread support
  1610. # do this before the optional library checks as some of them require pthreads
  1611. if enabled pthreads; then
  1612. if check_func pthread_create; then
  1613. :
  1614. elif check_func pthread_create -pthread; then
  1615. add_cflags -pthread
  1616. add_extralibs -pthread
  1617. elif check_func pthread_create -pthreads; then
  1618. add_cflags -pthreads
  1619. add_extralibs -pthreads
  1620. elif check_func pthread_create -lpthreadGC2; then
  1621. add_extralibs -lpthreadGC2
  1622. elif ! check_lib pthread.h pthread_create -lpthread; then
  1623. die "ERROR: can't find pthreads library"
  1624. fi
  1625. fi
  1626. for thread in $THREADS_LIST; do
  1627. if enabled $thread; then
  1628. test -n "$thread_type" &&
  1629. die "ERROR: Only one thread type must be selected." ||
  1630. thread_type="$thread"
  1631. fi
  1632. done
  1633. check_lib math.h sin -lm
  1634. # test for C99 functions in math.h
  1635. for func in llrint lrint lrintf round roundf; do
  1636. check_exec <<EOF && enable $func || disable $func
  1637. #include <math.h>
  1638. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1639. EOF
  1640. done
  1641. # these are off by default, so fail if requested and not available
  1642. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1643. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1644. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1645. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  1646. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
  1647. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
  1648. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1649. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1650. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1651. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1652. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1653. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  1654. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  1655. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  1656. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1657. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1658. enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm &&
  1659. { check_cpp_condition x264.h "X264_BUILD >= 65" ||
  1660. die "ERROR: libx264 version must be >= 0.65."; }
  1661. enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
  1662. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1663. # libdc1394 check
  1664. if enabled libdc1394; then
  1665. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1666. enable libdc1394_2; } ||
  1667. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1668. enable libdc1394_1; } ||
  1669. die "ERROR: No version of libdc1394 found "
  1670. fi
  1671. _restrict=
  1672. for restrict_keyword in restrict __restrict__ __restrict; do
  1673. check_cc <<EOF && _restrict=$restrict_keyword && break
  1674. void foo(char * $restrict_keyword p);
  1675. EOF
  1676. done
  1677. test "$vhook" = "default" && vhook="$dlopen"
  1678. if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
  1679. disable vhook
  1680. echo
  1681. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1682. echo "Patches welcome."
  1683. echo
  1684. fi
  1685. if enabled vhook; then
  1686. check_ldflags -rdynamic
  1687. check_ldflags -export-dynamic
  1688. fi
  1689. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1690. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1691. ##########################################
  1692. # SDL check
  1693. disable sdl_too_old
  1694. disable sdl
  1695. SDL_CONFIG="${cross_prefix}sdl-config"
  1696. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  1697. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1698. temp_cflags $sdl_cflags
  1699. temp_extralibs `"${SDL_CONFIG}" --libs`
  1700. if check_lib2 SDL.h SDL_Init; then
  1701. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1702. if test "$_sdlversion" -lt 121 ; then
  1703. enable sdl_too_old
  1704. else
  1705. enable sdl
  1706. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1707. #include <SDL.h>
  1708. int main(int argc, char **argv){
  1709. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1710. int w = vi->current_w;
  1711. return 0;
  1712. }
  1713. EOF
  1714. fi
  1715. fi
  1716. restore_flags
  1717. fi
  1718. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  1719. ##########################################
  1720. # Network check
  1721. if enabled network; then
  1722. check_type sys/socket.h socklen_t
  1723. # Prefer arpa/inet.h over winsock2
  1724. if check_header arpa/inet.h ; then
  1725. check_func closesocket
  1726. elif check_header winsock2.h ; then
  1727. network_extralibs="-lws2_32"
  1728. check_type ws2tcpip.h socklen_t
  1729. check_func_headers winsock2.h closesocket
  1730. fi
  1731. fi
  1732. ##########################################
  1733. # IPv6 check
  1734. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1735. #include <sys/types.h>
  1736. #include <sys/socket.h>
  1737. #include <netinet/in.h>
  1738. #include <netdb.h>
  1739. int main(void) {
  1740. struct sockaddr_storage saddr;
  1741. struct ipv6_mreq mreq6;
  1742. getaddrinfo(0,0,0,0);
  1743. getnameinfo(0,0,0,0,0,0,0);
  1744. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1745. }
  1746. EOF
  1747. check_header linux/videodev.h
  1748. check_header linux/videodev2.h
  1749. check_header sys/videoio.h
  1750. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1751. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1752. { check_header dev/bktr/ioctl_meteor.h &&
  1753. check_header dev/bktr/ioctl_bt848.h; } ||
  1754. { check_header machine/ioctl_meteor.h &&
  1755. check_header machine/ioctl_bt848.h; } ||
  1756. { check_header dev/video/meteor/ioctl_meteor.h &&
  1757. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1758. check_header dev/ic/bt8xx.h
  1759. check_header sys/soundcard.h
  1760. check_header soundcard.h
  1761. # deal with the X11 frame grabber
  1762. enabled x11grab &&
  1763. check_header X11/Xlib.h &&
  1764. check_header X11/extensions/XShm.h &&
  1765. check_func XOpenDisplay -lX11 &&
  1766. check_func XShmCreateImage -lX11 -lXext
  1767. enabled debug && add_cflags -g"$debuglevel"
  1768. # add some useful compiler flags if supported
  1769. check_cflags -Wdeclaration-after-statement
  1770. check_cflags -Wall
  1771. check_cflags -Wno-switch
  1772. check_cflags -Wdisabled-optimization
  1773. check_cflags -Wpointer-arith
  1774. check_cflags -Wredundant-decls
  1775. check_cflags -Wno-pointer-sign
  1776. check_cflags -Wcast-qual
  1777. check_cflags -Wwrite-strings
  1778. check_cflags -Wtype-limits
  1779. enabled extra_warnings && check_cflags -Winline
  1780. # add some linker flags
  1781. check_ldflags -Wl,--warn-common
  1782. check_ldflags -Wl,--as-needed
  1783. 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'
  1784. check_ldflags -Wl,-Bsymbolic
  1785. if enabled small; then
  1786. check_cflags -Os # not all compilers support -Os
  1787. optimizations="small"
  1788. elif enabled optimizations; then
  1789. if $cc -v 2>&1 | grep -q xlc; then
  1790. add_cflags "-O5"
  1791. add_ldflags "-O5"
  1792. else
  1793. add_cflags "-O3"
  1794. fi
  1795. fi
  1796. check_cflags -fno-math-errno
  1797. check_cflags -fno-signed-zeros
  1798. # add some flags for Intel C Compiler
  1799. if $cc --version 2> /dev/null | grep -q Intel; then
  1800. # Just warnings, no remarks
  1801. check_cflags -w1
  1802. # -wd: Disable following warnings
  1803. # 144, 167, 556: -Wno-pointer-sign
  1804. # 10006: ignoring unknown option -fno-signed-zeros
  1805. # 10156: ignoring option '-W'; no argument required
  1806. check_cflags -wd144,167,556,10006,10156
  1807. # 11030: Warning unknown option --as-needed
  1808. # 10156: ignoring option '-export'; no argument required
  1809. check_ldflags -wd10156,11030
  1810. # Allow to compile with optimizations
  1811. check_ldflags -march=$cpu
  1812. fi
  1813. # PIC flags for shared library objects where they are needed
  1814. if enabled shared; then
  1815. # LIBOBJFLAGS may have already been set in the OS configuration
  1816. if test -z "$LIBOBJFLAGS" ; then
  1817. case "$arch" in
  1818. x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
  1819. esac
  1820. fi
  1821. fi
  1822. if enabled gprof; then
  1823. add_cflags "-p"
  1824. add_ldflags "-p"
  1825. fi
  1826. VHOOKCFLAGS="-fPIC"
  1827. # Find out if the .align argument is a power of two or not.
  1828. if test $asmalign_pot = "unknown"; then
  1829. disable asmalign_pot
  1830. echo '__asm__ (".align 3");' | check_cc && enable asmalign_pot
  1831. fi
  1832. enabled_any $DECODER_LIST && enable decoders
  1833. enabled_any $ENCODER_LIST && enable encoders
  1834. enabled_any $BSF_LIST && enable bsfs
  1835. enabled_any $DEMUXER_LIST && enable demuxers
  1836. enabled_any $MUXER_LIST && enable muxers
  1837. enabled_any $FILTER_LIST && enable filters
  1838. enabled_any $INDEV_LIST && enable demuxers
  1839. enabled_any $OUTDEV_LIST && enable muxers
  1840. enabled_any $PROTOCOL_LIST && enable protocols
  1841. enabled_any $THREADS_LIST && enable threads
  1842. check_deps $CONFIG_LIST \
  1843. $CONFIG_EXTRA \
  1844. $HAVE_LIST \
  1845. $DECODER_LIST \
  1846. $ENCODER_LIST \
  1847. $PARSER_LIST \
  1848. $BSF_LIST \
  1849. $DEMUXER_LIST \
  1850. $MUXER_LIST \
  1851. $FILTER_LIST \
  1852. $INDEV_LIST \
  1853. $OUTDEV_LIST \
  1854. $PROTOCOL_LIST \
  1855. enabled libdc1394 && append pkg_requires "libraw1394"
  1856. enabled libdirac && append pkg_requires "dirac"
  1857. enabled libtheora && append pkg_requires "theora"
  1858. enabled libvorbis && append pkg_requires "vorbisenc"
  1859. echo "install prefix $prefix"
  1860. echo "source path $source_path"
  1861. echo "C compiler $cc"
  1862. echo ".align is power-of-two $asmalign_pot"
  1863. echo "ARCH $arch ($cpu)"
  1864. if test "$build_suffix" != ""; then
  1865. echo "build suffix $build_suffix"
  1866. fi
  1867. if test "$extra_version" != ""; then
  1868. echo "version string suffix $extra_version"
  1869. fi
  1870. echo "big-endian ${bigendian-no}"
  1871. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1872. echo "yasm ${yasm-no}"
  1873. echo "MMX enabled ${mmx-no}"
  1874. echo "CMOV enabled ${cmov-no}"
  1875. echo "CMOV is fast ${fast_cmov-no}"
  1876. echo "EBX available ${ebx_available-no}"
  1877. echo "EBP available ${ebp_available-no}"
  1878. fi
  1879. if test $arch = "armv4l"; then
  1880. echo "ARMv5TE enabled ${armv5te-no}"
  1881. echo "ARMv6 enabled ${armv6-no}"
  1882. echo "ARM VFP enabled ${armvfp-no}"
  1883. echo "IWMMXT enabled ${iwmmxt-no}"
  1884. echo "NEON enabled ${neon-no}"
  1885. fi
  1886. if test $arch = "mips"; then
  1887. echo "MMI enabled ${mmi-no}"
  1888. fi
  1889. if test $arch = "powerpc"; then
  1890. echo "AltiVec enabled ${altivec-no}"
  1891. echo "dcbzl available ${dcbzl-no}"
  1892. fi
  1893. echo "gprof enabled ${gprof-no}"
  1894. echo "debug symbols ${debug-no}"
  1895. echo "strip symbols ${stripping-no}"
  1896. echo "optimizations ${optimizations-no}"
  1897. echo "static ${static-no}"
  1898. echo "shared ${shared-no}"
  1899. echo "postprocessing support ${postproc-no}"
  1900. echo "software scaler enabled ${swscale-no}"
  1901. echo "new filter support ${avfilter-no}"
  1902. echo "filters using lavformat ${avfilter_lavf-no}"
  1903. echo "video hooking ${vhook-no}"
  1904. if enabled vhook; then
  1905. echo "Imlib2 support ${imlib2-no}"
  1906. echo "FreeType support ${freetype2-no}"
  1907. fi
  1908. echo "network support ${network-no}"
  1909. if enabled network; then
  1910. echo "IPv6 support ${ipv6-no}"
  1911. fi
  1912. echo "threading support ${thread_type-no}"
  1913. echo "SDL support ${sdl-no}"
  1914. if enabled sdl_too_old; then
  1915. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1916. fi
  1917. echo "Sun medialib support ${mlib-no}"
  1918. echo "AVISynth enabled ${avisynth-no}"
  1919. echo "libamr-nb support ${libamr_nb-no}"
  1920. echo "libamr-wb support ${libamr_wb-no}"
  1921. echo "libdc1394 support ${libdc1394-no}"
  1922. echo "libdirac enabled ${libdirac-no}"
  1923. echo "libfaac enabled ${libfaac-no}"
  1924. echo "libfaad enabled ${libfaad-no}"
  1925. echo "libfaad dlopened ${libfaadbin-no}"
  1926. echo "libgsm enabled ${libgsm-no}"
  1927. echo "libmp3lame enabled ${libmp3lame-no}"
  1928. echo "libnut enabled ${libnut-no}"
  1929. echo "libschroedinger enabled ${libschroedinger-no}"
  1930. echo "libspeex enabled ${libspeex-no}"
  1931. echo "libtheora enabled ${libtheora-no}"
  1932. echo "libvorbis enabled ${libvorbis-no}"
  1933. echo "libx264 enabled ${libx264-no}"
  1934. echo "libxvid enabled ${libxvid-no}"
  1935. echo "zlib enabled ${zlib-no}"
  1936. echo "bzlib enabled ${bzlib-no}"
  1937. echo
  1938. for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
  1939. echo "Enabled ${type}s:"
  1940. eval list=\$$(toupper $type)_LIST
  1941. for part in $list; do
  1942. enabled $part && echo ${part%_*}
  1943. done | sort | pr -3 -t
  1944. echo
  1945. done
  1946. license="LGPL"
  1947. if enabled nonfree; then
  1948. license="unredistributable"
  1949. elif enabled gpl; then
  1950. license="GPL"
  1951. fi
  1952. echo "License: $license"
  1953. echo "Creating config.mak and config.h..."
  1954. echo "# Automatically generated by configure - do not modify!" > config.mak
  1955. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1956. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  1957. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  1958. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1959. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  1960. echo "prefix=$prefix" >> config.mak
  1961. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  1962. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  1963. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  1964. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  1965. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  1966. echo "CC=$cc" >> config.mak
  1967. echo "YASM=$yasmexe" >> config.mak
  1968. echo "AR=$ar" >> config.mak
  1969. echo "RANLIB=$ranlib" >> config.mak
  1970. echo "LN_S=$ln_s" >> config.mak
  1971. enabled stripping &&
  1972. echo "STRIP=$strip" >> config.mak ||
  1973. echo "STRIP=echo ignoring strip" >> config.mak
  1974. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1975. echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
  1976. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1977. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1978. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1979. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  1980. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1981. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1982. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1983. echo "BUILD_STATIC=$static" >> config.mak
  1984. echo "BUILDSUF=$build_suffix" >> config.mak
  1985. echo "FULLNAME=$FULLNAME" >> config.mak
  1986. echo "LIBPREF=$LIBPREF" >> config.mak
  1987. echo "LIBSUF=$LIBSUF" >> config.mak
  1988. echo "LIBNAME=$LIBNAME" >> config.mak
  1989. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1990. echo "SLIBSUF=$SLIBSUF" >> config.mak
  1991. echo "EXESUF=$EXESUF" >> config.mak
  1992. echo "EXTRA_VERSION=$extra_version" >> config.mak
  1993. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  1994. if enabled bigendian; then
  1995. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1996. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1997. fi
  1998. if enabled sdl; then
  1999. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  2000. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  2001. fi
  2002. if enabled texi2html; then
  2003. echo "BUILD_DOC=yes" >> config.mak
  2004. fi
  2005. get_version(){
  2006. name=$1
  2007. file=$source_path/$2
  2008. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2009. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2010. lcname=$(tolower $name)
  2011. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2012. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2013. }
  2014. get_version LIBSWSCALE libswscale/swscale.h
  2015. get_version LIBPOSTPROC libpostproc/postprocess.h
  2016. get_version LIBAVCODEC libavcodec/avcodec.h
  2017. get_version LIBAVDEVICE libavdevice/avdevice.h
  2018. get_version LIBAVFORMAT libavformat/avformat.h
  2019. get_version LIBAVUTIL libavutil/avutil.h
  2020. get_version LIBAVFILTER libavfilter/avfilter.h
  2021. if enabled shared; then
  2022. echo "BUILD_SHARED=yes" >> config.mak
  2023. echo "PIC=-fPIC -DPIC" >> config.mak
  2024. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  2025. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  2026. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  2027. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  2028. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  2029. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  2030. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  2031. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  2032. fi
  2033. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  2034. echo "EXTRALIBS=$extralibs" >> config.mak
  2035. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2036. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2037. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2038. $CONFIG_EXTRA \
  2039. $DECODER_LIST \
  2040. $ENCODER_LIST \
  2041. $PARSER_LIST \
  2042. $BSF_LIST \
  2043. $DEMUXER_LIST \
  2044. $MUXER_LIST \
  2045. $FILTER_LIST \
  2046. $PROTOCOL_LIST \
  2047. $INDEV_LIST \
  2048. $OUTDEV_LIST \
  2049. echo "#define restrict $_restrict" >> $TMPH
  2050. if enabled small; then
  2051. echo "#define av_always_inline" >> $TMPH
  2052. fi
  2053. echo "SRC_PATH=\"$source_path\"" >> config.mak
  2054. echo "SRC_PATH_BARE=$source_path" >> config.mak
  2055. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  2056. # Apparently it's not possible to portably echo a backslash.
  2057. enabled asmalign_pot &&
  2058. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  2059. printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
  2060. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  2061. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2062. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2063. cmp -s $TMPH config.h &&
  2064. echo "config.h is unchanged" ||
  2065. mv -f $TMPH config.h
  2066. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  2067. # build tree in object directory if source path is different from current one
  2068. if enabled source_path_used; then
  2069. DIRS="\
  2070. doc \
  2071. libavcodec \
  2072. libavcodec/alpha \
  2073. libavcodec/armv4l \
  2074. libavcodec/bfin \
  2075. libavcodec/i386 \
  2076. libavcodec/mlib \
  2077. libavcodec/ppc \
  2078. libavcodec/sh4 \
  2079. libavcodec/sparc \
  2080. libavdevice \
  2081. libavfilter \
  2082. libavformat \
  2083. libavutil \
  2084. libpostproc \
  2085. libswscale \
  2086. tests \
  2087. tools \
  2088. vhook \
  2089. "
  2090. FILES="\
  2091. Makefile \
  2092. common.mak \
  2093. subdir.mak \
  2094. doc/texi2pod.pl \
  2095. libavcodec/Makefile \
  2096. libavdevice/Makefile \
  2097. libavfilter/Makefile \
  2098. libavformat/Makefile \
  2099. libavutil/Makefile \
  2100. libpostproc/Makefile \
  2101. libswscale/Makefile \
  2102. "
  2103. for dir in $DIRS ; do
  2104. mkdir -p $dir
  2105. done
  2106. for f in $FILES ; do
  2107. $ln_s "$source_path/$f" $f
  2108. done
  2109. fi
  2110. # build pkg-config files
  2111. pkgconfig_generate(){
  2112. name=$1
  2113. shortname=${name#lib}
  2114. comment=$2
  2115. version=$3
  2116. libs=$4
  2117. requires=$5
  2118. cat <<EOF > $name/$name.pc
  2119. prefix=$prefix
  2120. exec_prefix=\${prefix}
  2121. libdir=$libdir
  2122. includedir=$incdir
  2123. Name: $name
  2124. Description: $comment
  2125. Version: $version
  2126. Requires: $(disabled shared && echo $requires)
  2127. Requires.private: $(enabled shared && echo $requires)
  2128. Conflicts:
  2129. Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
  2130. Libs.private: $(enabled shared && echo $libs)
  2131. Cflags: -I\${includedir}
  2132. EOF
  2133. cat <<EOF > $name/$name-uninstalled.pc
  2134. prefix=
  2135. exec_prefix=
  2136. libdir=\${pcfiledir}
  2137. includedir=${source_path}
  2138. Name: $name
  2139. Description: $comment
  2140. Version: $version
  2141. Requires: $requires
  2142. Conflicts:
  2143. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2144. Cflags: -I\${includedir}
  2145. EOF
  2146. }
  2147. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2148. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2149. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2150. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
  2151. enabled avfilter &&
  2152. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2153. enabled postproc &&
  2154. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2155. if enabled swscale; then
  2156. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  2157. else
  2158. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2159. apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
  2160. fi