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.

2269 lines
66KB

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