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.

2299 lines
66KB

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