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.

2271 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. enabled x86_64 && objformat="macho64"
  1155. ;;
  1156. mingw32*)
  1157. target_os=mingw32
  1158. LIBTARGET=i386
  1159. if test $arch = x86_64; then
  1160. disable need_memalign
  1161. LIBTARGET=x64
  1162. fi
  1163. shlibdir_default="$bindir_default"
  1164. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1165. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1166. if enabled swscale; then
  1167. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1168. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1169. fi
  1170. disable ffserver
  1171. SLIBPREF=""
  1172. SLIBSUF=".dll"
  1173. EXESUF=".exe"
  1174. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1175. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1176. SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1177. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1178. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
  1179. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1180. SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  1181. objformat="win32"
  1182. ;;
  1183. cygwin*)
  1184. target_os=cygwin
  1185. shlibdir_default="$bindir_default"
  1186. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1187. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1188. if enabled swscale; then
  1189. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1190. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1191. fi
  1192. EXESUF=".exe"
  1193. SLIBPREF="cyg"
  1194. SLIBSUF=".dll"
  1195. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1196. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1197. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1198. objformat="win32"
  1199. ;;
  1200. *-dos|freedos|opendos)
  1201. disable ffplay ffserver vhook
  1202. disable $INDEV_LIST $OUTDEV_LIST
  1203. network_extralibs="-lsocket"
  1204. EXESUF=".exe"
  1205. objformat="win32"
  1206. ;;
  1207. linux)
  1208. enable dv1394
  1209. ;;
  1210. irix*)
  1211. target_os=irix
  1212. ranlib="echo ignoring ranlib"
  1213. ;;
  1214. os/2*)
  1215. strip="lxlite"
  1216. ln_s="cp -f"
  1217. EXESUF=".exe"
  1218. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1219. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1220. FFSERVERLDFLAGS=""
  1221. LIBSUF="_s.a"
  1222. SLIBPREF=""
  1223. SLIBSUF=".dll"
  1224. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1225. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1226. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1227. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1228. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1229. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1230. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1231. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1232. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1233. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1234. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1235. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1236. disable vhook
  1237. ;;
  1238. interix)
  1239. disable vhook
  1240. ;;
  1241. *)
  1242. target_os="${target_os}-UNKNOWN"
  1243. ;;
  1244. esac
  1245. set_default $PATHS_LIST
  1246. add_extralibs $osextralibs
  1247. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1248. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1249. test -n "$cross_prefix" && enable cross_compile
  1250. # we need to build at least one lib type
  1251. if ! enabled_any static shared; then
  1252. cat <<EOF
  1253. At least one library type must be built.
  1254. Specify --enable-static to build the static libraries or --enable-shared to
  1255. build the shared libraries as well. To only build the shared libraries specify
  1256. --disable-static in addition to --enable-shared.
  1257. EOF
  1258. exit 1;
  1259. fi
  1260. disabled static && LIBNAME=""
  1261. if enabled_any libfaad libfaadbin ; then
  1262. if check_header faad.h; then
  1263. check_cc << EOF
  1264. #include <faad.h>
  1265. #ifndef FAAD2_VERSION
  1266. ok faad1
  1267. #endif
  1268. int main(void) { return 0; }
  1269. EOF
  1270. test $? = 0 && enable libfaad2
  1271. else
  1272. die "FAAD test failed."
  1273. fi
  1274. fi
  1275. if ! enabled gpl; then
  1276. die_gpl_disabled(){
  1277. name=$1
  1278. shift
  1279. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1280. }
  1281. die_gpl_disabled "The Postprocessing code" postproc
  1282. die_gpl_disabled "liba52" liba52
  1283. die_gpl_disabled "libx264" libx264
  1284. die_gpl_disabled "libxvidcore" libxvid
  1285. die_gpl_disabled "FAAD2" libfaad2
  1286. die_gpl_disabled "The X11 grabber" x11grab
  1287. die_gpl_disabled "The software scaler" swscale
  1288. fi
  1289. if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
  1290. die "libamr is nonfree and --enable-nonfree is not specified."
  1291. fi
  1292. check_deps $ARCH_EXT_LIST
  1293. test -z "$need_memalign" && need_memalign="$mmx"
  1294. #Darwin CC versions
  1295. if test $target_os = darwin; then
  1296. if $cc -v 2>&1 | grep -q xlc; then
  1297. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1298. else
  1299. add_cflags "-pipe"
  1300. check_cflags "-force_cpusubtype_ALL"
  1301. check_cflags "-Wno-sign-compare"
  1302. enabled shared || check_cflags -mdynamic-no-pic
  1303. fi
  1304. fi
  1305. disabled optimizations || check_cflags -fomit-frame-pointer
  1306. # Add processor-specific flags
  1307. if test $cpu != "generic"; then
  1308. warn_altivec(){
  1309. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1310. }
  1311. case $cpu in
  1312. 601|ppc601|PowerPC601)
  1313. add_cflags "-mcpu=601"
  1314. warn_altivec enabled PPC601
  1315. ;;
  1316. 603*|ppc603*|PowerPC603*)
  1317. add_cflags "-mcpu=603"
  1318. warn_altivec enabled PPC603
  1319. ;;
  1320. 604*|ppc604*|PowerPC604*)
  1321. add_cflags "-mcpu=604"
  1322. warn_altivec enabled PPC604
  1323. ;;
  1324. G3|g3|75*|ppc75*|PowerPC75*)
  1325. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1326. warn_altivec enabled PPC75x
  1327. ;;
  1328. G4|g4|745*|ppc745*|PowerPC745*)
  1329. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1330. warn_altivec disabled PPC745x
  1331. ;;
  1332. 74*|ppc74*|PowerPC74*)
  1333. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1334. warn_altivec disabled PPC74xx
  1335. ;;
  1336. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1337. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1338. warn_altivec disabled PPC970
  1339. enable ppc64
  1340. ;;
  1341. Cell|CELL|cell)
  1342. add_cflags "-mcpu=cell"
  1343. warn_altivec disabled Cell
  1344. enable ppc64
  1345. ;;
  1346. # targets that do NOT support conditional mov (cmov)
  1347. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1348. add_cflags "-march=$cpu"
  1349. disable cmov
  1350. ;;
  1351. # targets that do support conditional mov (cmov)
  1352. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1353. add_cflags "-march=$cpu"
  1354. enable cmov
  1355. enable fast_cmov
  1356. ;;
  1357. # targets that do support conditional mov but on which it's slow
  1358. pentium4|pentium4m|prescott|nocona)
  1359. add_cflags "-march=$cpu"
  1360. enable cmov
  1361. disable fast_cmov
  1362. ;;
  1363. sparc64)
  1364. add_cflags "-mcpu=v9"
  1365. ;;
  1366. arm*|cortex*)
  1367. add_cflags "-mcpu=$cpu"
  1368. ;;
  1369. *)
  1370. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1371. ;;
  1372. esac
  1373. fi
  1374. # make sure we can execute files in $TMPDIR
  1375. cat > $TMPSH 2>> $logfile <<EOF
  1376. #! /bin/sh
  1377. EOF
  1378. chmod +x $TMPSH >> $logfile 2>&1
  1379. if ! $TMPSH >> $logfile 2>&1; then
  1380. cat <<EOF
  1381. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1382. variable to another directory and make sure that $TMPDIR1 is not mounted
  1383. noexec.
  1384. EOF
  1385. die "Sanity test failed."
  1386. fi
  1387. rm $TMPSH
  1388. # compiler sanity check
  1389. check_exec <<EOF
  1390. int main(void){ return 0; }
  1391. EOF
  1392. if test "$?" != 0; then
  1393. echo "$cc is unable to create an executable file."
  1394. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1395. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1396. echo "Only do this if you know what cross compiling means."
  1397. fi
  1398. die "C compiler test failed."
  1399. fi
  1400. check_cc <<EOF || die "Symbol mangling check failed."
  1401. int ff_extern;
  1402. EOF
  1403. sym=$($nm -P -g $TMPO | grep ff_extern)
  1404. extern_prefix=${sym%%ff_extern*}
  1405. check_asm inline_asm '""'
  1406. if enabled x86; then
  1407. # check whether EBP is available on x86
  1408. # As 'i' is stored on the stack, this program will crash
  1409. # if the base pointer is used to access it because the
  1410. # base pointer is cleared in the inline assembly code.
  1411. check_exec_crash <<EOF && enable ebp_available
  1412. volatile int i=0;
  1413. asm volatile (
  1414. "xorl %%ebp, %%ebp"
  1415. ::: "%ebp");
  1416. return i;
  1417. EOF
  1418. # check wether EBX is available on x86
  1419. check_asm ebx_available '"":::"%ebx"'
  1420. # check whether binutils is new enough to compile SSSE3/MMX2
  1421. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1422. enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
  1423. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1424. YASMFLAGS="-f $objformat -DARCH_$(toupper $arch)"
  1425. enabled x86_64 && append YASMFLAGS "-m amd64"
  1426. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  1427. case "$objformat" in
  1428. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  1429. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  1430. *) append YASMFLAGS "-DPREFIX" ;;
  1431. esac
  1432. check_yasm "pabsw xmm0, xmm0" && enable yasm
  1433. fi
  1434. # check for assembler specific support
  1435. if test $arch = "powerpc"; then
  1436. check_cc <<EOF && enable dcbzl
  1437. int main(void) {
  1438. register long zero = 0;
  1439. char data[1024];
  1440. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1441. return 0;
  1442. }
  1443. EOF
  1444. fi
  1445. # check for SIMD availability
  1446. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1447. if enabled altivec; then
  1448. check_cflags -maltivec -mabi=altivec &&
  1449. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1450. check_cflags -faltivec
  1451. # check if our compiler supports Motorola AltiVec C API
  1452. check_cc <<EOF || disable altivec
  1453. $inc_altivec_h
  1454. int main(void) {
  1455. vector signed int v1, v2, v3;
  1456. v1 = vec_add(v2,v3);
  1457. return 0;
  1458. }
  1459. EOF
  1460. # check if our compiler supports braces for vector declarations
  1461. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1462. $inc_altivec_h
  1463. int main (void) { (vector int) {1}; return 0; }
  1464. EOF
  1465. fi
  1466. # We have to check if pld is a nop and disable it.
  1467. enabled armv4l && check_asm pld '"pld [r0]"'
  1468. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1469. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1470. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1471. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1472. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1473. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1474. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1475. enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
  1476. # ---
  1477. # big/little-endian test
  1478. check_cc <<EOF || die "endian test failed"
  1479. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1480. EOF
  1481. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1482. # ---
  1483. # check availability of some header files
  1484. if check_func dlopen; then
  1485. ldl=
  1486. elif check_func dlopen -ldl; then
  1487. ldl=-ldl
  1488. fi
  1489. check_func fork
  1490. check_func gethrtime
  1491. check_func getrusage
  1492. check_func inet_aton $network_extralibs
  1493. check_func memalign
  1494. check_func mkstemp
  1495. check_func2 windows.h GetProcessTimes
  1496. check_header byteswap.h
  1497. check_header conio.h
  1498. check_header dlfcn.h
  1499. check_header malloc.h
  1500. check_header poll.h
  1501. check_header sys/mman.h
  1502. check_header sys/resource.h
  1503. check_header sys/select.h
  1504. check_header termios.h
  1505. if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
  1506. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1507. fi
  1508. enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
  1509. enabled bzlib && check_lib bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  1510. # check for some common methods of building with pthread support
  1511. # do this before the optional library checks as some of them require pthreads
  1512. if enabled pthreads; then
  1513. if check_func pthread_create; then
  1514. :
  1515. elif check_func pthread_create -pthread; then
  1516. add_cflags -pthread
  1517. add_extralibs -pthread
  1518. elif check_func pthread_create -pthreads; then
  1519. add_cflags -pthreads
  1520. add_extralibs -pthreads
  1521. elif check_func pthread_create -lpthreadGC2; then
  1522. add_extralibs -lpthreadGC2
  1523. elif ! check_lib pthread.h pthread_create -lpthread; then
  1524. die "ERROR: can't find pthreads library"
  1525. fi
  1526. fi
  1527. for thread in $THREADS_LIST; do
  1528. if enabled $thread; then
  1529. test -n "$thread_type" &&
  1530. die "ERROR: Only one thread type must be selected." ||
  1531. thread_type="$thread"
  1532. fi
  1533. done
  1534. check_lib math.h sin -lm
  1535. # test for C99 functions in math.h
  1536. for func in llrint lrint lrintf round roundf; do
  1537. check_exec <<EOF && enable $func || disable $func
  1538. #include <math.h>
  1539. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1540. EOF
  1541. done
  1542. # these are off by default, so fail if requested and not available
  1543. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1544. enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
  1545. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1546. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1547. enabled libdirac && add_cflags "$(pkg-config --cflags dirac)" \
  1548. && require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder \
  1549. && require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
  1550. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1551. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1552. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1553. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1554. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1555. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) \
  1556. && require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  1557. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1558. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1559. enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm
  1560. enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
  1561. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1562. # libdc1394 check
  1563. if enabled libdc1394; then
  1564. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1565. enable libdc1394_2; } ||
  1566. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1567. enable libdc1394_1; } ||
  1568. die "ERROR: No version of libdc1394 found "
  1569. fi
  1570. _restrict=
  1571. for restrict_keyword in restrict __restrict__ __restrict; do
  1572. check_cc <<EOF && _restrict=$restrict_keyword && break
  1573. void foo(char * $restrict_keyword p);
  1574. EOF
  1575. done
  1576. test "$vhook" = "default" && vhook="$dlopen"
  1577. if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
  1578. disable vhook
  1579. echo
  1580. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1581. echo "Patches welcome."
  1582. echo
  1583. fi
  1584. if enabled vhook; then
  1585. check_ldflags -rdynamic
  1586. check_ldflags -export-dynamic
  1587. fi
  1588. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1589. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1590. ##########################################
  1591. # SDL check
  1592. disable sdl_too_old
  1593. disable sdl
  1594. SDL_CONFIG="${cross_prefix}sdl-config"
  1595. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  1596. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1597. temp_cflags $sdl_cflags
  1598. temp_extralibs `"${SDL_CONFIG}" --libs`
  1599. if check_lib2 SDL.h SDL_Init; then
  1600. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1601. if test "$_sdlversion" -lt 121 ; then
  1602. enable sdl_too_old
  1603. else
  1604. enable sdl
  1605. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1606. #include <SDL.h>
  1607. int main(int argc, char **argv){
  1608. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1609. int w = vi->current_w;
  1610. return 0;
  1611. }
  1612. EOF
  1613. fi
  1614. fi
  1615. restore_flags
  1616. fi
  1617. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  1618. ##########################################
  1619. # Network check
  1620. if enabled network; then
  1621. check_type sys/socket.h socklen_t
  1622. # Prefer arpa/inet.h over winsock2
  1623. if check_header arpa/inet.h ; then
  1624. check_func closesocket
  1625. elif check_header winsock2.h ; then
  1626. network_extralibs="-lws2_32"
  1627. check_type ws2tcpip.h socklen_t
  1628. check_func2 winsock2.h closesocket
  1629. fi
  1630. fi
  1631. ##########################################
  1632. # IPv6 check
  1633. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1634. #include <sys/types.h>
  1635. #include <sys/socket.h>
  1636. #include <netinet/in.h>
  1637. #include <netdb.h>
  1638. int main(void) {
  1639. struct sockaddr_storage saddr;
  1640. struct ipv6_mreq mreq6;
  1641. getaddrinfo(0,0,0,0);
  1642. getnameinfo(0,0,0,0,0,0,0);
  1643. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1644. }
  1645. EOF
  1646. check_header linux/videodev.h
  1647. check_header linux/videodev2.h
  1648. check_func2 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1649. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1650. { check_header dev/bktr/ioctl_meteor.h &&
  1651. check_header dev/bktr/ioctl_bt848.h; } ||
  1652. { check_header machine/ioctl_meteor.h &&
  1653. check_header machine/ioctl_bt848.h; } ||
  1654. { check_header dev/video/meteor/ioctl_meteor.h &&
  1655. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1656. check_header dev/ic/bt8xx.h
  1657. check_header sys/soundcard.h
  1658. check_header soundcard.h
  1659. # deal with the X11 frame grabber
  1660. enabled x11grab &&
  1661. check_header X11/Xlib.h &&
  1662. check_header X11/extensions/XShm.h &&
  1663. check_func XOpenDisplay -lX11 &&
  1664. check_func XShmCreateImage -lX11 -lXext
  1665. enabled debug && add_cflags -g"$debuglevel"
  1666. # add some useful compiler flags if supported
  1667. check_cflags -Wdeclaration-after-statement
  1668. check_cflags -Wall
  1669. check_cflags -Wno-switch
  1670. check_cflags -Wdisabled-optimization
  1671. check_cflags -Wpointer-arith
  1672. check_cflags -Wredundant-decls
  1673. check_cflags -Wno-pointer-sign
  1674. check_cflags -Wcast-qual
  1675. check_cflags -Wwrite-strings
  1676. check_cflags -Wtype-limits
  1677. enabled extra_warnings && check_cflags -Winline
  1678. # add some linker flags
  1679. check_ldflags -Wl,--warn-common
  1680. check_ldflags -Wl,--as-needed
  1681. 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'
  1682. check_ldflags -Wl,-Bsymbolic
  1683. if enabled small; then
  1684. check_cflags -Os # not all compilers support -Os
  1685. optimizations="small"
  1686. elif enabled optimizations; then
  1687. if $cc -v 2>&1 | grep -q xlc; then
  1688. add_cflags "-O5"
  1689. add_ldflags "-O5"
  1690. else
  1691. add_cflags "-O3"
  1692. fi
  1693. fi
  1694. check_cflags -fno-math-errno
  1695. check_cflags -fno-signed-zeros
  1696. # add some flags for Intel C Compiler
  1697. if $cc --version | grep -q Intel; then
  1698. # Just warnings, no remarks
  1699. check_cflags -w1
  1700. # -wd: Disable following warnings
  1701. # 144, 167, 556: -Wno-pointer-sign
  1702. # 10006: ignoring unknown option -fno-signed-zeros
  1703. # 10156: ignoring option '-W'; no argument required
  1704. check_cflags -wd144,167,556,10006,10156
  1705. # 11030: Warning unknown option --as-needed
  1706. # 10156: ignoring option '-export'; no argument required
  1707. check_ldflags -wd10156,11030
  1708. # Allow to compile with optimizations
  1709. check_ldflags -march=$cpu
  1710. fi
  1711. # PIC flags for shared library objects where they are needed
  1712. if enabled shared; then
  1713. # LIBOBJFLAGS may have already been set in the OS configuration
  1714. if test -z "$LIBOBJFLAGS" ; then
  1715. case "$arch" in
  1716. x86_64|ia64|alpha|sparc*|power*|parisc*) LIBOBJFLAGS='$(PIC)' ;;
  1717. esac
  1718. fi
  1719. fi
  1720. if enabled gprof; then
  1721. add_cflags "-p"
  1722. add_ldflags "-p"
  1723. fi
  1724. VHOOKCFLAGS="-fPIC"
  1725. # Find out if the .align argument is a power of two or not.
  1726. if test $asmalign_pot = "unknown"; then
  1727. disable asmalign_pot
  1728. echo 'asm (".align 3");' | check_cc && enable asmalign_pot
  1729. fi
  1730. enabled_any $DECODER_LIST && enable decoders
  1731. enabled_any $ENCODER_LIST && enable encoders
  1732. enabled_any $BSF_LIST && enable bsfs
  1733. enabled_any $DEMUXER_LIST && enable demuxers
  1734. enabled_any $MUXER_LIST && enable muxers
  1735. enabled_any $FILTER_LIST && enable filters
  1736. enabled_any $INDEV_LIST && enable demuxers
  1737. enabled_any $OUTDEV_LIST && enable muxers
  1738. enabled_any $PROTOCOL_LIST && enable protocols
  1739. enabled_any $THREADS_LIST && enable threads
  1740. check_deps $CONFIG_LIST \
  1741. $HAVE_LIST \
  1742. $DECODER_LIST \
  1743. $ENCODER_LIST \
  1744. $PARSER_LIST \
  1745. $BSF_LIST \
  1746. $DEMUXER_LIST \
  1747. $MUXER_LIST \
  1748. $FILTER_LIST \
  1749. $INDEV_LIST \
  1750. $OUTDEV_LIST \
  1751. $PROTOCOL_LIST \
  1752. enabled libdc1394 && append pkg_requires "libraw1394"
  1753. enabled libdirac && append pkg_requires "dirac"
  1754. enabled libtheora && append pkg_requires "theora"
  1755. enabled libvorbis && append pkg_requires "vorbisenc"
  1756. echo "install prefix $prefix"
  1757. echo "source path $source_path"
  1758. echo "C compiler $cc"
  1759. echo ".align is power-of-two $asmalign_pot"
  1760. echo "ARCH $arch ($cpu)"
  1761. if test "$build_suffix" != ""; then
  1762. echo "build suffix $build_suffix"
  1763. fi
  1764. echo "big-endian ${bigendian-no}"
  1765. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1766. echo "yasm ${yasm-no}"
  1767. echo "MMX enabled ${mmx-no}"
  1768. echo "CMOV enabled ${cmov-no}"
  1769. echo "CMOV is fast ${fast_cmov-no}"
  1770. echo "EBX available ${ebx_available-no}"
  1771. echo "EBP available ${ebp_available-no}"
  1772. fi
  1773. if test $arch = "armv4l"; then
  1774. echo "ARMv5TE enabled ${armv5te-no}"
  1775. echo "ARMv6 enabled ${armv6-no}"
  1776. echo "ARM VFP enabled ${armvfp-no}"
  1777. echo "IWMMXT enabled ${iwmmxt-no}"
  1778. echo "NEON enabled ${neon-no}"
  1779. fi
  1780. if test $arch = "mips"; then
  1781. echo "MMI enabled ${mmi-no}"
  1782. fi
  1783. if test $arch = "powerpc"; then
  1784. echo "AltiVec enabled ${altivec-no}"
  1785. echo "dcbzl available ${dcbzl-no}"
  1786. fi
  1787. echo "gprof enabled ${gprof-no}"
  1788. echo "debug symbols ${debug-no}"
  1789. echo "strip symbols ${stripping-no}"
  1790. echo "optimizations ${optimizations-no}"
  1791. echo "static ${static-no}"
  1792. echo "shared ${shared-no}"
  1793. echo "postprocessing support ${postproc-no}"
  1794. echo "software scaler enabled ${swscale-no}"
  1795. echo "new filter support ${avfilter-no}"
  1796. echo "filters using lavformat ${avfilter_lavf-no}"
  1797. echo "video hooking ${vhook-no}"
  1798. if enabled vhook; then
  1799. echo "Imlib2 support ${imlib2-no}"
  1800. echo "FreeType support ${freetype2-no}"
  1801. fi
  1802. echo "network support ${network-no}"
  1803. if enabled network; then
  1804. echo "IPv6 support ${ipv6-no}"
  1805. fi
  1806. echo "threading support ${thread_type-no}"
  1807. echo "SDL support ${sdl-no}"
  1808. if enabled sdl_too_old; then
  1809. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1810. fi
  1811. echo "Sun medialib support ${mlib-no}"
  1812. echo "AVISynth enabled ${avisynth-no}"
  1813. echo "liba52 support ${liba52-no}"
  1814. echo "liba52 dlopened ${liba52bin-no}"
  1815. echo "libamr-nb support ${libamr_nb-no}"
  1816. echo "libamr-wb support ${libamr_wb-no}"
  1817. echo "libdc1394 support ${libdc1394-no}"
  1818. echo "libdirac enabled ${libdirac-no}"
  1819. echo "libfaac enabled ${libfaac-no}"
  1820. echo "libfaad enabled ${libfaad-no}"
  1821. echo "libfaad dlopened ${libfaadbin-no}"
  1822. echo "libgsm enabled ${libgsm-no}"
  1823. echo "libmp3lame enabled ${libmp3lame-no}"
  1824. echo "libnut enabled ${libnut-no}"
  1825. echo "libschroedinger enabled ${libschroedinger-no}"
  1826. echo "libtheora enabled ${libtheora-no}"
  1827. echo "libvorbis enabled ${libvorbis-no}"
  1828. echo "libx264 enabled ${libx264-no}"
  1829. echo "libxvid enabled ${libxvid-no}"
  1830. echo "zlib enabled ${zlib-no}"
  1831. echo "bzlib enabled ${bzlib-no}"
  1832. echo
  1833. for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
  1834. echo "Enabled ${type}s:"
  1835. eval list=\$$(toupper $type)_LIST
  1836. for part in $list; do
  1837. enabled $part && echo ${part%_*}
  1838. done | sort | pr -3 -t
  1839. echo
  1840. done
  1841. license="LGPL"
  1842. if enabled nonfree; then
  1843. license="unredistributable"
  1844. elif enabled gpl; then
  1845. license="GPL"
  1846. fi
  1847. echo "License: $license"
  1848. echo "Creating config.mak and config.h..."
  1849. echo "# Automatically generated by configure - do not modify!" > config.mak
  1850. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1851. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  1852. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  1853. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1854. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  1855. echo "prefix=$prefix" >> config.mak
  1856. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  1857. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  1858. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  1859. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  1860. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  1861. echo "CC=$cc" >> config.mak
  1862. echo "YASM=$yasmexe" >> config.mak
  1863. echo "AR=$ar" >> config.mak
  1864. echo "RANLIB=$ranlib" >> config.mak
  1865. echo "LN_S=$ln_s" >> config.mak
  1866. enabled stripping &&
  1867. echo "STRIP=$strip" >> config.mak ||
  1868. echo "STRIP=echo ignoring strip" >> config.mak
  1869. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1870. echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
  1871. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1872. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1873. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1874. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  1875. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1876. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1877. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1878. echo "BUILD_STATIC=$static" >> config.mak
  1879. echo "BUILDSUF=$build_suffix" >> config.mak
  1880. echo "FULLNAME=$FULLNAME" >> config.mak
  1881. echo "LIBPREF=$LIBPREF" >> config.mak
  1882. echo "LIBSUF=$LIBSUF" >> config.mak
  1883. echo "LIBNAME=$LIBNAME" >> config.mak
  1884. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1885. echo "SLIBSUF=$SLIBSUF" >> config.mak
  1886. echo "EXESUF=$EXESUF" >> config.mak
  1887. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  1888. if enabled bigendian; then
  1889. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1890. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1891. fi
  1892. if enabled sdl; then
  1893. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1894. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1895. fi
  1896. if enabled texi2html; then
  1897. echo "BUILD_DOC=yes" >> config.mak
  1898. fi
  1899. get_version(){
  1900. name=$1
  1901. file=$source_path/$2
  1902. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  1903. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  1904. lcname=$(tolower $name)
  1905. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  1906. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  1907. }
  1908. get_version LIBSWSCALE libswscale/swscale.h
  1909. get_version LIBPOSTPROC libpostproc/postprocess.h
  1910. get_version LIBAVCODEC libavcodec/avcodec.h
  1911. get_version LIBAVDEVICE libavdevice/avdevice.h
  1912. get_version LIBAVFORMAT libavformat/avformat.h
  1913. get_version LIBAVUTIL libavutil/avutil.h
  1914. get_version LIBAVFILTER libavfilter/avfilter.h
  1915. if enabled shared; then
  1916. echo "BUILD_SHARED=yes" >> config.mak
  1917. echo "PIC=-fPIC -DPIC" >> config.mak
  1918. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  1919. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1920. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1921. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1922. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  1923. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1924. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1925. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  1926. fi
  1927. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1928. echo "EXTRALIBS=$extralibs" >> config.mak
  1929. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  1930. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1931. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  1932. $DECODER_LIST \
  1933. $ENCODER_LIST \
  1934. $PARSER_LIST \
  1935. $BSF_LIST \
  1936. $DEMUXER_LIST \
  1937. $MUXER_LIST \
  1938. $FILTER_LIST \
  1939. $PROTOCOL_LIST \
  1940. $INDEV_LIST \
  1941. $OUTDEV_LIST \
  1942. echo "#define restrict $_restrict" >> $TMPH
  1943. if enabled small; then
  1944. echo "#define av_always_inline" >> $TMPH
  1945. fi
  1946. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1947. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1948. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1949. # Apparently it's not possible to portably echo a backslash.
  1950. enabled asmalign_pot &&
  1951. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  1952. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1953. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  1954. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  1955. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  1956. cmp -s $TMPH config.h &&
  1957. echo "config.h is unchanged" ||
  1958. mv -f $TMPH config.h
  1959. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  1960. # build tree in object directory if source path is different from current one
  1961. if enabled source_path_used; then
  1962. DIRS="\
  1963. doc \
  1964. libavcodec \
  1965. libavcodec/alpha \
  1966. libavcodec/armv4l \
  1967. libavcodec/bfin \
  1968. libavcodec/i386 \
  1969. libavcodec/mlib \
  1970. libavcodec/ppc \
  1971. libavcodec/sh4 \
  1972. libavcodec/sparc \
  1973. libavdevice \
  1974. libavfilter \
  1975. libavformat \
  1976. libavutil \
  1977. libpostproc \
  1978. libswscale \
  1979. tests \
  1980. tools \
  1981. vhook \
  1982. "
  1983. FILES="\
  1984. Makefile \
  1985. common.mak \
  1986. subdir.mak \
  1987. doc/texi2pod.pl \
  1988. libavcodec/Makefile \
  1989. libavdevice/Makefile \
  1990. libavfilter/Makefile \
  1991. libavformat/Makefile \
  1992. libavutil/Makefile \
  1993. libpostproc/Makefile \
  1994. libswscale/Makefile \
  1995. "
  1996. for dir in $DIRS ; do
  1997. mkdir -p $dir
  1998. done
  1999. for f in $FILES ; do
  2000. $ln_s "$source_path/$f" $f
  2001. done
  2002. fi
  2003. # build pkg-config files
  2004. pkgconfig_generate(){
  2005. name=$1
  2006. shortname=${name#lib}
  2007. comment=$2
  2008. version=$3
  2009. libs=$4
  2010. requires=$5
  2011. cat <<EOF > $name/$name.pc
  2012. prefix=$prefix
  2013. exec_prefix=\${prefix}
  2014. libdir=$libdir
  2015. includedir=$incdir
  2016. Name: $name
  2017. Description: $comment
  2018. Version: $version
  2019. Requires: $(disabled shared && echo $requires)
  2020. Requires.private: $(enabled shared && echo $requires)
  2021. Conflicts:
  2022. Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
  2023. Libs.private: $(enabled shared && echo $libs)
  2024. Cflags: -I\${includedir}
  2025. EOF
  2026. cat <<EOF > $name/$name-uninstalled.pc
  2027. prefix=
  2028. exec_prefix=
  2029. libdir=\${pcfiledir}
  2030. includedir=\${pcfiledir}/..
  2031. Name: $name
  2032. Description: $comment
  2033. Version: $version
  2034. Requires: $requires
  2035. Conflicts:
  2036. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2037. Cflags: -I\${includedir}
  2038. EOF
  2039. }
  2040. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2041. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2042. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2043. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
  2044. enabled avfilter &&
  2045. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2046. enabled postproc &&
  2047. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2048. if enabled swscale; then
  2049. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  2050. else
  2051. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2052. apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
  2053. fi