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.

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