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.

2305 lines
67KB

  1. #!/bin/sh
  2. #
  3. # FFmpeg configure script
  4. #
  5. # Copyright (c) 2000-2002 Fabrice Bellard
  6. # Copyright (c) 2005-2008 Diego Biurrun
  7. # Copyright (c) 2005-2008 Mans Rullgard
  8. #
  9. # Prevent locale nonsense from breaking basic text processing.
  10. LC_ALL=C
  11. export LC_ALL
  12. # make sure we are running under a compatible shell
  13. # try to make this part work with most shells
  14. try_exec(){
  15. echo "Trying shell $1"
  16. type "$1" > /dev/null 2>&1 && exec "$@"
  17. }
  18. unset foo
  19. (: ${foo%%bar}) 2> /dev/null
  20. E1="$?"
  21. (: ${foo?}) 2> /dev/null
  22. E2="$?"
  23. if test "$E1" != 0 || test "$E2" = 0; then
  24. echo "Broken shell detected. Trying alternatives."
  25. export FF_CONF_EXEC
  26. if test "0$FF_CONF_EXEC" -lt 1; then
  27. FF_CONF_EXEC=1
  28. try_exec bash "$0" "$@"
  29. fi
  30. if test "0$FF_CONF_EXEC" -lt 2; then
  31. FF_CONF_EXEC=2
  32. try_exec ksh "$0" "$@"
  33. fi
  34. if test "0$FF_CONF_EXEC" -lt 3; then
  35. FF_CONF_EXEC=3
  36. try_exec /usr/xpg4/bin/sh "$0" "$@"
  37. fi
  38. echo "No compatible shell script interpreter found."
  39. echo "This configure script requires a POSIX-compatible shell"
  40. echo "such as bash or ksh."
  41. echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
  42. echo "Instead, install a working POSIX-compatible shell."
  43. echo "Disabling this configure test will create a broken FFmpeg."
  44. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  45. echo "This bash version ($BASH_VERSION) is broken on your platform."
  46. echo "Upgrade to a later version if available."
  47. fi
  48. exit 1
  49. fi
  50. show_help(){
  51. echo "Usage: configure [options]"
  52. echo "Options: [defaults in brackets after descriptions]"
  53. echo
  54. echo "Standard options:"
  55. echo " --help print this message"
  56. echo " --logfile=FILE log tests and output to FILE [config.err]"
  57. echo " --disable-logging do not log configure debug information"
  58. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  59. echo " --bindir=DIR install binaries in DIR [PREFIX/bin]"
  60. echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
  61. echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
  62. echo " --incdir=DIR install includes in DIR [PREFIX/include]"
  63. echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
  64. echo " --enable-static build static libraries [default=yes]"
  65. echo " --disable-static do not build static libraries [default=no]"
  66. echo " --enable-shared build shared libraries [default=no]"
  67. echo " --disable-shared do not build shared libraries [default=yes]"
  68. echo " --enable-gpl allow use of GPL code, the resulting libav*"
  69. echo " and ffmpeg will be under GPL [default=no]"
  70. echo " --enable-nonfree allow use of nonfree code, the resulting libav*"
  71. echo " and ffmpeg will be unredistributable [default=no]"
  72. echo " --enable-postproc enable GPLed postprocessing support [default=no]"
  73. echo " --enable-swscale software scaler support [default=no]"
  74. echo " --enable-avfilter video filter support (replaces vhook) [default=no]"
  75. echo " --enable-avfilter-lavf video filters dependant on avformat [default=no]"
  76. echo " --enable-beosthreads use BeOS threads [default=no]"
  77. echo " --enable-os2threads use OS/2 threads [default=no]"
  78. echo " --enable-pthreads use pthreads [default=no]"
  79. echo " --enable-w32threads use Win32 threads [default=no]"
  80. echo " --enable-x11grab enable X11 grabbing [default=no]"
  81. echo
  82. echo "External library support:"
  83. echo " --enable-mlib use Sun medialib [default=no]"
  84. echo " --enable-avisynth allow reading AVISynth script files [default=no]"
  85. echo " --enable-libamr-nb enable libamr-nb floating point audio codec"
  86. echo " --enable-libamr-wb enable libamr-wb floating point audio codec"
  87. echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
  88. echo " and libraw1394 [default=no]"
  89. echo " --enable-libdirac enable Dirac support via libdirac [default=no]"
  90. echo " --enable-libfaac enable FAAC support via libfaac [default=no]"
  91. echo " --enable-libfaad enable FAAD support via libfaad [default=no]"
  92. echo " --enable-libfaadbin open libfaad.so.0 at runtime [default=no]"
  93. echo " --enable-libgsm enable GSM support via libgsm [default=no]"
  94. echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [default=no]"
  95. echo " --enable-libnut enable NUT (de)muxing via libnut,"
  96. echo " native demuxer exists [default=no]"
  97. echo " --enable-libschroedinger enable Dirac support via libschroedinger [default=no]"
  98. echo " --enable-libspeex enable Speex decoding via libspeex [default=no]"
  99. echo " --enable-libtheora enable Theora encoding via libtheora [default=no]"
  100. echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
  101. echo " native implementation exists [default=no]"
  102. echo " --enable-libx264 enable H.264 encoding via x264 [default=no]"
  103. echo " --enable-libxvid enable Xvid encoding via xvidcore,"
  104. echo " native MPEG-4/Xvid encoder exists [default=no]"
  105. echo ""
  106. echo "Advanced options (experts only):"
  107. echo " --source-path=PATH path to source code [$source_path]"
  108. echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
  109. echo " --enable-cross-compile assume a cross-compiler is used"
  110. echo " --target-os=OS compiler targets OS [$target_os]"
  111. echo " --cc=CC use C compiler CC [$cc]"
  112. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  113. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  114. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  115. echo " --extra-version=STRING version string suffix []"
  116. echo " --build-suffix=SUFFIX suffix for application specific build []"
  117. echo " --arch=ARCH select architecture [$arch]"
  118. echo " --cpu=CPU selects the minimum cpu required (affects"
  119. echo " instruction selection, may crash on older CPUs)"
  120. echo " --enable-powerpc-perf enable performance report on PPC"
  121. echo " (requires enabling PMC)"
  122. echo " --disable-mmx disable MMX usage"
  123. echo " --disable-mmx2 disable MMX2 usage"
  124. echo " --disable-ssse3 disable SSSE3 usage"
  125. echo " --disable-armv5te disable armv5te usage"
  126. echo " --disable-armv6 disable armv6 usage"
  127. echo " --disable-armvfp disable ARM VFP usage"
  128. echo " --disable-iwmmxt disable iwmmxt usage"
  129. echo " --disable-altivec disable AltiVec usage"
  130. echo " --disable-network disable network support [default=no]"
  131. echo " --disable-ipv6 disable ipv6 support [default=no]"
  132. echo " --disable-zlib disable zlib [default=no]"
  133. echo " --disable-bzlib disable bzlib [default=no]"
  134. echo " --disable-vhook disable video hooking support"
  135. echo " --disable-mpegaudio-hp faster (but less accurate)"
  136. echo " MPEG audio decoding [default=no]"
  137. echo " --enable-gray enable full grayscale support (slower color)"
  138. echo " --disable-ffmpeg disable ffmpeg build"
  139. echo " --disable-ffserver disable ffserver build"
  140. echo " --disable-ffplay disable ffplay build"
  141. echo " --enable-small optimize for size instead of speed"
  142. echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
  143. echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
  144. echo " --disable-encoder=NAME disables encoder NAME"
  145. echo " --enable-encoder=NAME enables encoder NAME"
  146. echo " --disable-decoder=NAME disables decoder NAME"
  147. echo " --enable-decoder=NAME enables decoder NAME"
  148. echo " --disable-encoders disables all encoders"
  149. echo " --disable-decoders disables all decoders"
  150. echo " --disable-muxer=NAME disables muxer NAME"
  151. echo " --enable-muxer=NAME enables muxer NAME"
  152. echo " --disable-muxers disables all muxers"
  153. echo " --disable-demuxer=NAME disables demuxer NAME"
  154. echo " --enable-demuxer=NAME enables demuxer NAME"
  155. echo " --disable-demuxers disables all demuxers"
  156. echo " --enable-parser=NAME enables parser NAME"
  157. echo " --disable-parser=NAME disables parser NAME"
  158. echo " --disable-parsers disables all parsers"
  159. echo " --enable-bsf=NAME enables bitstream filter NAME"
  160. echo " --disable-bsf=NAME disables bitstream filter NAME"
  161. echo " --disable-bsfs disables all bitstream filters"
  162. echo " --enable-protocol=NAME enables protocol NAME"
  163. echo " --disable-protocol=NAME disables protocol NAME"
  164. echo " --disable-protocols disables all protocols"
  165. echo " --disable-devices disables all devices"
  166. echo " --enable-filter=NAME enables filter NAME"
  167. echo " --disable-filter=NAME disables filter NAME"
  168. echo " --disable-filters disables all filters"
  169. echo " --list-decoders show all available decoders"
  170. echo " --list-encoders show all available encoders"
  171. echo " --list-muxers show all available muxers"
  172. echo " --list-demuxers show all available demuxers"
  173. echo " --list-parsers show all available parsers"
  174. echo " --list-protocols show all available protocols"
  175. echo " --list-bsfs show all available bitstream filters"
  176. echo " --list-indevs show all available input devices"
  177. echo " --list-outdevs show all available output devices"
  178. echo " --list-filters show all available filters"
  179. echo
  180. echo "Developer options (useful when working on FFmpeg itself):"
  181. echo " --disable-debug disable debugging symbols"
  182. echo " --enable-debug=LEVEL set the debug level [$debuglevel]"
  183. echo " --enable-gprof enable profiling with gprof [$gprof]"
  184. echo " --disable-optimizations disable compiler optimizations"
  185. echo " --enable-extra-warnings enable more compiler warnings"
  186. echo " --disable-stripping disable stripping of executables and shared libraries"
  187. echo ""
  188. echo "NOTE: Object files are built at the place where configure is launched."
  189. exit 0
  190. }
  191. log(){
  192. echo "$@" >> $logfile
  193. }
  194. log_file(){
  195. log BEGIN $1
  196. pr -n -t $1 >> $logfile
  197. log END $1
  198. }
  199. echolog(){
  200. log "$@"
  201. echo "$@"
  202. }
  203. die(){
  204. echolog "$@"
  205. cat <<EOF
  206. If you think configure made a mistake, make sure you are using the latest
  207. version from SVN. If the latest version fails, report the problem to the
  208. ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  209. EOF
  210. if disabled logging; then
  211. cat <<EOF
  212. Rerun configure with logging enabled (do not use --disable-logging), and
  213. include the log this produces with your report.
  214. EOF
  215. else
  216. cat <<EOF
  217. Include the log file "$logfile" produced by configure as this will help
  218. solving the problem.
  219. EOF
  220. fi
  221. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  222. exit 1
  223. }
  224. # Avoid locale weirdness, besides we really just want to translate ASCII.
  225. toupper(){
  226. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  227. }
  228. tolower(){
  229. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  230. }
  231. set_all(){
  232. value=$1
  233. shift
  234. for var in $*; do
  235. eval $var=$value
  236. done
  237. }
  238. pushvar(){
  239. for var in $*; do
  240. eval level=\${${var}_level:=0}
  241. eval ${var}_${level}="\$$var"
  242. eval ${var}_level=$(($level+1))
  243. done
  244. }
  245. popvar(){
  246. for var in $*; do
  247. eval level=\${${var}_level:-0}
  248. test $level = 0 && continue
  249. eval level=$(($level-1))
  250. eval $var="\${${var}_${level}}"
  251. eval ${var}_level=$level
  252. eval unset ${var}_${level}
  253. done
  254. }
  255. enable(){
  256. set_all yes $*
  257. }
  258. disable(){
  259. set_all no $*
  260. }
  261. enabled(){
  262. test "${1#!}" = "$1" && op== || op=!=
  263. eval test "x\$${1#!}" $op "xyes"
  264. }
  265. disabled(){
  266. test "${1#!}" = "$1" && op== || op=!=
  267. eval test "x\$${1#!}" $op "xno"
  268. }
  269. enabled_all(){
  270. for opt; do
  271. enabled $opt || return 1
  272. done
  273. }
  274. disabled_all(){
  275. for opt; do
  276. disabled $opt || return 1
  277. done
  278. }
  279. enabled_any(){
  280. for opt; do
  281. enabled $opt && return 0
  282. done
  283. }
  284. disabled_any(){
  285. for opt; do
  286. disabled $opt && return 0
  287. done
  288. return 1
  289. }
  290. set_default(){
  291. for opt; do
  292. eval test -z "\$$opt" && eval $opt=\$${opt}_default
  293. done
  294. }
  295. is_in(){
  296. value=$1
  297. shift
  298. for var in $*; do
  299. [ $var = $value ] && return 0
  300. done
  301. return 1
  302. }
  303. check_deps(){
  304. for cfg; do
  305. cfg="${cfg#!}"
  306. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  307. disabled ${cfg}_checking && continue
  308. enable ${cfg}_checking
  309. eval dep_all="\$${cfg}_deps"
  310. eval dep_any="\$${cfg}_deps_any"
  311. eval dep_sel="\$${cfg}_select"
  312. pushvar cfg dep_all dep_any dep_sel
  313. check_deps $dep_all $dep_any $dep_sel
  314. popvar cfg dep_all dep_any dep_sel
  315. enabled_all $dep_all || disable $cfg
  316. enabled_any $dep_any || disable $cfg
  317. disabled_any $dep_sel && disable $cfg
  318. if enabled $cfg; then
  319. eval dep_extralibs="\$${cfg}_extralibs"
  320. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  321. enable $dep_sel
  322. fi
  323. disable ${cfg}_checking
  324. done
  325. }
  326. print_config(){
  327. pfx=$1
  328. header=$2
  329. makefile=$3
  330. shift 3
  331. for cfg; do
  332. ucname="`toupper $cfg`"
  333. if enabled $cfg; then
  334. echo "#define ${pfx}${ucname} 1" >> $header
  335. echo "#define ENABLE_${ucname} 1" >> $header
  336. echo "${pfx}${ucname}=yes" >> $makefile
  337. else
  338. echo "#define ENABLE_${ucname} 0" >> $header
  339. fi
  340. done
  341. }
  342. flags_saved(){
  343. (: ${SAVE_CFLAGS?}) 2> /dev/null
  344. }
  345. save_flags(){
  346. flags_saved && return
  347. SAVE_CFLAGS="$CFLAGS"
  348. SAVE_LDFLAGS="$LDFLAGS"
  349. SAVE_extralibs="$extralibs"
  350. }
  351. restore_flags(){
  352. flags_saved || return
  353. CFLAGS="$SAVE_CFLAGS"
  354. LDFLAGS="$SAVE_LDFLAGS"
  355. extralibs="$SAVE_extralibs"
  356. unset SAVE_CFLAGS
  357. unset SAVE_LDFLAGS
  358. unset SAVE_extralibs
  359. }
  360. temp_cflags(){
  361. save_flags
  362. CFLAGS="$CFLAGS $*"
  363. }
  364. temp_ldflags(){
  365. save_flags
  366. LDFLAGS="$LDFLAGS $*"
  367. }
  368. temp_extralibs(){
  369. save_flags
  370. extralibs="$extralibs $*"
  371. }
  372. append(){
  373. var=$1
  374. shift
  375. flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
  376. eval "$var=\"\$$var $*\""
  377. }
  378. add_cflags(){
  379. append CFLAGS "$@"
  380. }
  381. add_ldflags(){
  382. append LDFLAGS "$@"
  383. }
  384. add_extralibs(){
  385. append extralibs "$@"
  386. }
  387. check_cmd(){
  388. log "$@"
  389. "$@" >> $logfile 2>&1
  390. }
  391. check_cc(){
  392. log check_cc "$@"
  393. cat > $TMPC
  394. log_file $TMPC
  395. check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
  396. }
  397. check_cpp(){
  398. log check_cpp "$@"
  399. cat > $TMPC
  400. log_file $TMPC
  401. check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
  402. }
  403. check_asm(){
  404. log check_asm "$@"
  405. name="$1"
  406. asm="$2"
  407. shift 2
  408. check_cc "$@" <<EOF && enable $name || disable $name
  409. int foo(void){ __asm__ volatile($asm); }
  410. EOF
  411. }
  412. check_yasm(){
  413. log check_yasm "$@"
  414. echo "$1" > $TMPS
  415. log_file $TMPS
  416. shift 1
  417. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  418. }
  419. check_ld(){
  420. log check_ld "$@"
  421. check_cc || return
  422. flags=''
  423. libs=''
  424. for f; do
  425. test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
  426. done
  427. check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
  428. }
  429. check_cflags(){
  430. log check_cflags "$@"
  431. check_cc "$@" <<EOF && add_cflags "$@"
  432. int x;
  433. EOF
  434. }
  435. check_ldflags(){
  436. log check_ldflags "$@"
  437. check_ld "$@" <<EOF && add_ldflags "$@"
  438. int main(void){ return 0; }
  439. EOF
  440. }
  441. check_header(){
  442. log check_header "$@"
  443. header=$1
  444. shift
  445. var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
  446. disable $var
  447. check_cpp "$@" <<EOF && enable $var
  448. #include <$header>
  449. int x;
  450. EOF
  451. }
  452. check_func(){
  453. log check_func "$@"
  454. func=$1
  455. shift
  456. disable $func
  457. check_ld "$@" <<EOF && enable $func
  458. extern int $func();
  459. int main(void){ $func(); }
  460. EOF
  461. }
  462. check_func_headers(){
  463. log check_func_headers "$@"
  464. headers=$1
  465. func=$2
  466. shift 2
  467. disable $func
  468. incs=""
  469. for hdr in $headers; do
  470. incs="$incs
  471. #include <$hdr>"
  472. done
  473. check_ld "$@" <<EOF && enable $func
  474. $incs
  475. int main(int argc, char **argv){
  476. (void) $func;
  477. return 0;
  478. }
  479. EOF
  480. }
  481. check_cpp_condition(){
  482. log check_cpp_condition "$@"
  483. header=$1
  484. condition=$2
  485. check_cpp <<EOF
  486. #include <$header>
  487. #if !($condition)
  488. #error "unsatisfied condition: $condition"
  489. #endif
  490. EOF
  491. }
  492. check_lib(){
  493. log check_lib "$@"
  494. header="$1"
  495. func="$2"
  496. shift 2
  497. temp_extralibs "$@"
  498. check_header $header && check_func $func && add_extralibs "$@"
  499. err=$?
  500. restore_flags
  501. return $err
  502. }
  503. check_lib2(){
  504. log check_lib2 "$@"
  505. headers="$1"
  506. func="$2"
  507. shift 2
  508. temp_extralibs "$@"
  509. check_func_headers "$headers" $func && add_extralibs "$@"
  510. err=$?
  511. restore_flags
  512. return $err
  513. }
  514. check_exec(){
  515. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  516. }
  517. check_exec_crash(){
  518. code=`cat`
  519. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  520. # are safe but may not be available everywhere. Thus we use
  521. # raise(SIGTERM) instead. The check is run in a subshell so we
  522. # can redirect the "Terminated" message from the shell. SIGBUS
  523. # is not defined by standard C so it is used conditionally.
  524. (check_exec "$@") >> $logfile 2>&1 <<EOF
  525. #include <signal.h>
  526. static void sighandler(int sig){
  527. raise(SIGTERM);
  528. }
  529. int main(void){
  530. signal(SIGILL, sighandler);
  531. signal(SIGFPE, sighandler);
  532. signal(SIGSEGV, sighandler);
  533. #ifdef SIGBUS
  534. signal(SIGBUS, sighandler);
  535. #endif
  536. { $code }
  537. }
  538. EOF
  539. }
  540. check_type(){
  541. log check_type "$@"
  542. headers=$1
  543. type=$2
  544. shift 2
  545. disable $type
  546. incs=""
  547. for hdr in $headers; do
  548. incs="$incs
  549. #include <$hdr>"
  550. done
  551. check_cc "$@" <<EOF && enable $type
  552. $incs
  553. $type v;
  554. EOF
  555. }
  556. require(){
  557. name="$1"
  558. header="$2"
  559. func="$3"
  560. shift 3
  561. check_lib $header $func "$@" || die "ERROR: $name not found"
  562. }
  563. require2(){
  564. name="$1"
  565. headers="$2"
  566. func="$3"
  567. shift 3
  568. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  569. }
  570. check_foo_config(){
  571. cfg=$1
  572. pkg=$2
  573. header=$3
  574. func=$4
  575. shift 4
  576. disable $cfg
  577. check_cmd ${pkg}-config --version
  578. err=$?
  579. if test "$err" = 0; then
  580. temp_cflags `${pkg}-config --cflags`
  581. temp_extralibs `${pkg}-config --libs`
  582. check_lib "$@" $header $func && enable $cfg
  583. fi
  584. return $err
  585. }
  586. apply(){
  587. file=$1
  588. shift
  589. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  590. }
  591. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  592. # system-dependent things.
  593. COMPONENT_LIST="
  594. bsfs
  595. decoders
  596. demuxers
  597. encoders
  598. filters
  599. indevs
  600. muxers
  601. outdevs
  602. parsers
  603. protocols
  604. "
  605. CONFIG_LIST="
  606. $COMPONENT_LIST
  607. avfilter
  608. avfilter_lavf
  609. avisynth
  610. beos_netserver
  611. bzlib
  612. ffmpeg
  613. ffplay
  614. ffserver
  615. gpl
  616. gprof
  617. gray
  618. hardcoded_tables
  619. ipv6
  620. libamr_nb
  621. libamr_wb
  622. libdc1394
  623. libdirac
  624. libfaac
  625. libfaad
  626. libfaadbin
  627. libgsm
  628. libmp3lame
  629. libnut
  630. libschroedinger
  631. libspeex
  632. libtheora
  633. libvorbis
  634. libx264
  635. libxvid
  636. memalign_hack
  637. mlib
  638. mpegaudio_hp
  639. network
  640. nonfree
  641. postproc
  642. powerpc_perf
  643. small
  644. swscale
  645. vhook
  646. x11grab
  647. zlib
  648. "
  649. THREADS_LIST='
  650. beosthreads
  651. os2threads
  652. pthreads
  653. w32threads
  654. '
  655. ARCH_LIST='
  656. alpha
  657. armv4l
  658. bfin
  659. ia64
  660. m68k
  661. mips
  662. parisc
  663. powerpc
  664. s390
  665. sh4
  666. sparc
  667. sparc64
  668. x86
  669. x86_32
  670. x86_64
  671. '
  672. ARCH_EXT_LIST='
  673. altivec
  674. armv5te
  675. armv6
  676. armvfp
  677. iwmmxt
  678. mmi
  679. mmx
  680. mmx2
  681. neon
  682. ssse3
  683. vis
  684. '
  685. HAVE_LIST="
  686. $ARCH_EXT_LIST
  687. $THREADS_LIST
  688. altivec_h
  689. arpa_inet_h
  690. bswap
  691. closesocket
  692. cmov
  693. conio_h
  694. dcbzl
  695. dev_bktr_ioctl_bt848_h
  696. dev_bktr_ioctl_meteor_h
  697. dev_ic_bt8xx_h
  698. dev_video_meteor_ioctl_meteor_h
  699. dev_video_bktr_ioctl_bt848_h
  700. dlfcn_h
  701. dlopen
  702. dos_paths
  703. ebp_available
  704. ebx_available
  705. fast_64bit
  706. fast_cmov
  707. fast_unaligned
  708. fork
  709. freetype2
  710. gethrtime
  711. GetProcessTimes
  712. getrusage
  713. imlib2
  714. inet_aton
  715. inline_asm
  716. libdc1394_1
  717. libdc1394_2
  718. llrint
  719. lrint
  720. lrintf
  721. machine_ioctl_bt848_h
  722. machine_ioctl_meteor_h
  723. malloc_h
  724. memalign
  725. mkstemp
  726. pld
  727. ppc64
  728. round
  729. roundf
  730. sdl
  731. sdl_video_size
  732. socklen_t
  733. soundcard_h
  734. poll_h
  735. sys_mman_h
  736. sys_resource_h
  737. sys_select_h
  738. sys_soundcard_h
  739. sys_videoio_h
  740. termios_h
  741. threads
  742. winsock2_h
  743. yasm
  744. "
  745. CMDLINE_SELECT="
  746. $ARCH_EXT_LIST
  747. $CONFIG_LIST
  748. $THREADS_LIST
  749. cross_compile
  750. debug
  751. extra_warnings
  752. logging
  753. optimizations
  754. shared
  755. static
  756. stripping
  757. "
  758. PATHS_LIST='
  759. bindir
  760. incdir
  761. libdir
  762. mandir
  763. prefix
  764. shlibdir
  765. '
  766. CMDLINE_SET="
  767. $PATHS_LIST
  768. arch
  769. build_suffix
  770. cc
  771. cpu
  772. cross_prefix
  773. extra_version
  774. logfile
  775. source_path
  776. target_os
  777. "
  778. # code dependency declarations
  779. # architecture extensions
  780. altivec_deps="powerpc"
  781. armv5te_deps="armv4l"
  782. armv6_deps="armv4l"
  783. armvfp_deps="armv4l"
  784. iwmmxt_deps="armv4l"
  785. mmi_deps="mips"
  786. mmx_deps="x86"
  787. mmx2_deps="x86 mmx"
  788. neon_deps="armv4l"
  789. ssse3_deps="x86"
  790. vis_deps="sparc"
  791. # decoders / encoders
  792. ac3_decoder_deps="gpl"
  793. dxa_decoder_deps="zlib"
  794. eac3_decoder_deps="gpl"
  795. flashsv_decoder_deps="zlib"
  796. flashsv_encoder_deps="zlib"
  797. mlp_decoder_deps="mlp_parser"
  798. mpeg_xvmc_decoder_deps="xvmc"
  799. png_decoder_deps="zlib"
  800. png_encoder_deps="zlib"
  801. zmbv_decoder_deps="zlib"
  802. zmbv_encoder_deps="zlib"
  803. # external libraries
  804. libamr_nb_decoder_deps="libamr_nb"
  805. libamr_nb_encoder_deps="libamr_nb"
  806. libamr_wb_decoder_deps="libamr_wb"
  807. libamr_wb_encoder_deps="libamr_wb"
  808. libdirac_decoder_deps="libdirac !libschroedinger"
  809. libdirac_encoder_deps="libdirac"
  810. libfaac_encoder_deps="libfaac"
  811. libfaad_decoder_deps="libfaad"
  812. libfaadbin_decoder_extralibs='$ldl'
  813. libgsm_decoder_deps="libgsm"
  814. libgsm_encoder_deps="libgsm"
  815. libgsm_ms_decoder_deps="libgsm"
  816. libgsm_ms_encoder_deps="libgsm"
  817. libmp3lame_encoder_deps="libmp3lame"
  818. libschroedinger_decoder_deps="libschroedinger"
  819. libschroedinger_encoder_deps="libschroedinger"
  820. libspeex_decoder_deps="libspeex"
  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_default="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 "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," -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_default="${cross_prefix}${cc_default}"
  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_default cc
  1029. # set temporary file name
  1030. if test ! -z "$TMPDIR" ; then
  1031. TMPDIR1="${TMPDIR}"
  1032. elif test ! -z "$TEMPDIR" ; then
  1033. TMPDIR1="${TEMPDIR}"
  1034. else
  1035. TMPDIR1="/tmp"
  1036. fi
  1037. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  1038. TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
  1039. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  1040. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  1041. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  1042. TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
  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. armv*)
  1398. add_cflags "-march=$cpu"
  1399. ;;
  1400. arm*)
  1401. add_cflags "-mcpu=$cpu"
  1402. ;;
  1403. *)
  1404. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1405. ;;
  1406. esac
  1407. fi
  1408. # make sure we can execute files in $TMPDIR
  1409. cat > $TMPSH 2>> $logfile <<EOF
  1410. #! /bin/sh
  1411. EOF
  1412. chmod +x $TMPSH >> $logfile 2>&1
  1413. if ! $TMPSH >> $logfile 2>&1; then
  1414. cat <<EOF
  1415. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1416. variable to another directory and make sure that $TMPDIR1 is not mounted
  1417. noexec.
  1418. EOF
  1419. die "Sanity test failed."
  1420. fi
  1421. rm $TMPSH
  1422. # compiler sanity check
  1423. check_exec <<EOF
  1424. int main(void){ return 0; }
  1425. EOF
  1426. if test "$?" != 0; then
  1427. echo "$cc is unable to create an executable file."
  1428. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1429. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1430. echo "Only do this if you know what cross compiling means."
  1431. fi
  1432. die "C compiler test failed."
  1433. fi
  1434. check_cc <<EOF || die "Symbol mangling check failed."
  1435. int ff_extern;
  1436. EOF
  1437. sym=$($nm -P -g $TMPO | grep ff_extern)
  1438. extern_prefix=${sym%%ff_extern*}
  1439. check_asm inline_asm '""'
  1440. if enabled x86; then
  1441. # check whether EBP is available on x86
  1442. # As 'i' is stored on the stack, this program will crash
  1443. # if the base pointer is used to access it because the
  1444. # base pointer is cleared in the inline assembly code.
  1445. check_exec_crash <<EOF && enable ebp_available
  1446. volatile int i=0;
  1447. __asm__ volatile (
  1448. "xorl %%ebp, %%ebp"
  1449. ::: "%ebp");
  1450. return i;
  1451. EOF
  1452. # check wether EBX is available on x86
  1453. check_asm ebx_available '"":::"%ebx"'
  1454. # check whether binutils is new enough to compile SSSE3/MMX2
  1455. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1456. enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
  1457. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1458. YASMFLAGS="-f $objformat -DARCH_$(toupper $arch)"
  1459. enabled x86_64 && append YASMFLAGS "-m amd64"
  1460. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  1461. case "$objformat" in
  1462. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  1463. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  1464. *) append YASMFLAGS "-DPREFIX" ;;
  1465. esac
  1466. check_yasm "pabsw xmm0, xmm0" && enable yasm
  1467. fi
  1468. # check for assembler specific support
  1469. if test $arch = "powerpc"; then
  1470. check_asm dcbzl '"dcbzl 0, 1"'
  1471. fi
  1472. # check for SIMD availability
  1473. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1474. if enabled altivec; then
  1475. check_cflags -maltivec -mabi=altivec &&
  1476. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1477. check_cflags -faltivec
  1478. # check if our compiler supports Motorola AltiVec C API
  1479. check_cc <<EOF || disable altivec
  1480. $inc_altivec_h
  1481. int main(void) {
  1482. vector signed int v1, v2, v3;
  1483. v1 = vec_add(v2,v3);
  1484. return 0;
  1485. }
  1486. EOF
  1487. # check if our compiler supports braces for vector declarations
  1488. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1489. $inc_altivec_h
  1490. int main (void) { (vector int) {1}; return 0; }
  1491. EOF
  1492. fi
  1493. # We have to check if pld is a nop and disable it.
  1494. enabled armv4l && check_asm pld '"pld [r0]"'
  1495. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1496. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1497. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1498. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1499. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1500. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1501. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1502. enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
  1503. # ---
  1504. # big/little-endian test
  1505. check_cc <<EOF || die "endian test failed"
  1506. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1507. EOF
  1508. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1509. # ---
  1510. # check availability of some header files
  1511. if check_func dlopen; then
  1512. ldl=
  1513. elif check_func dlopen -ldl; then
  1514. ldl=-ldl
  1515. fi
  1516. check_func fork
  1517. check_func gethrtime
  1518. check_func getrusage
  1519. check_func inet_aton $network_extralibs
  1520. check_func memalign
  1521. check_func mkstemp
  1522. check_func_headers windows.h GetProcessTimes
  1523. check_header conio.h
  1524. check_header dlfcn.h
  1525. check_header malloc.h
  1526. check_header poll.h
  1527. check_header sys/mman.h
  1528. check_header sys/resource.h
  1529. check_header sys/select.h
  1530. check_header termios.h
  1531. if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
  1532. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1533. fi
  1534. enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
  1535. enabled bzlib && check_lib bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  1536. # check for some common methods of building with pthread support
  1537. # do this before the optional library checks as some of them require pthreads
  1538. if enabled pthreads; then
  1539. if check_func pthread_create; then
  1540. :
  1541. elif check_func pthread_create -pthread; then
  1542. add_cflags -pthread
  1543. add_extralibs -pthread
  1544. elif check_func pthread_create -pthreads; then
  1545. add_cflags -pthreads
  1546. add_extralibs -pthreads
  1547. elif check_func pthread_create -lpthreadGC2; then
  1548. add_extralibs -lpthreadGC2
  1549. elif ! check_lib pthread.h pthread_create -lpthread; then
  1550. die "ERROR: can't find pthreads library"
  1551. fi
  1552. fi
  1553. for thread in $THREADS_LIST; do
  1554. if enabled $thread; then
  1555. test -n "$thread_type" &&
  1556. die "ERROR: Only one thread type must be selected." ||
  1557. thread_type="$thread"
  1558. fi
  1559. done
  1560. check_lib math.h sin -lm
  1561. # test for C99 functions in math.h
  1562. for func in llrint lrint lrintf round roundf; do
  1563. check_exec <<EOF && enable $func || disable $func
  1564. #include <math.h>
  1565. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1566. EOF
  1567. done
  1568. # these are off by default, so fail if requested and not available
  1569. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1570. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1571. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1572. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  1573. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
  1574. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
  1575. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1576. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1577. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1578. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1579. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1580. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  1581. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  1582. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  1583. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1584. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1585. enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm &&
  1586. { check_cpp_condition x264.h "X264_BUILD >= 65" ||
  1587. die "ERROR: libx264 version must be >= 0.65."; }
  1588. enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
  1589. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1590. # libdc1394 check
  1591. if enabled libdc1394; then
  1592. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1593. enable libdc1394_2; } ||
  1594. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1595. enable libdc1394_1; } ||
  1596. die "ERROR: No version of libdc1394 found "
  1597. fi
  1598. _restrict=
  1599. for restrict_keyword in restrict __restrict__ __restrict; do
  1600. check_cc <<EOF && _restrict=$restrict_keyword && break
  1601. void foo(char * $restrict_keyword p);
  1602. EOF
  1603. done
  1604. test "$vhook" = "default" && vhook="$dlopen"
  1605. if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
  1606. disable vhook
  1607. echo
  1608. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1609. echo "Patches welcome."
  1610. echo
  1611. fi
  1612. if enabled vhook; then
  1613. check_ldflags -rdynamic
  1614. check_ldflags -export-dynamic
  1615. fi
  1616. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1617. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1618. ##########################################
  1619. # SDL check
  1620. disable sdl_too_old
  1621. disable sdl
  1622. SDL_CONFIG="${cross_prefix}sdl-config"
  1623. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  1624. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1625. temp_cflags $sdl_cflags
  1626. temp_extralibs `"${SDL_CONFIG}" --libs`
  1627. if check_lib2 SDL.h SDL_Init; then
  1628. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1629. if test "$_sdlversion" -lt 121 ; then
  1630. enable sdl_too_old
  1631. else
  1632. enable sdl
  1633. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1634. #include <SDL.h>
  1635. int main(int argc, char **argv){
  1636. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1637. int w = vi->current_w;
  1638. return 0;
  1639. }
  1640. EOF
  1641. fi
  1642. fi
  1643. restore_flags
  1644. fi
  1645. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  1646. ##########################################
  1647. # Network check
  1648. if enabled network; then
  1649. check_type sys/socket.h socklen_t
  1650. # Prefer arpa/inet.h over winsock2
  1651. if check_header arpa/inet.h ; then
  1652. check_func closesocket
  1653. elif check_header winsock2.h ; then
  1654. network_extralibs="-lws2_32"
  1655. check_type ws2tcpip.h socklen_t
  1656. check_func_headers winsock2.h closesocket
  1657. fi
  1658. fi
  1659. ##########################################
  1660. # IPv6 check
  1661. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1662. #include <sys/types.h>
  1663. #include <sys/socket.h>
  1664. #include <netinet/in.h>
  1665. #include <netdb.h>
  1666. int main(void) {
  1667. struct sockaddr_storage saddr;
  1668. struct ipv6_mreq mreq6;
  1669. getaddrinfo(0,0,0,0);
  1670. getnameinfo(0,0,0,0,0,0,0);
  1671. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1672. }
  1673. EOF
  1674. check_header linux/videodev.h
  1675. check_header linux/videodev2.h
  1676. check_header sys/videoio.h
  1677. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1678. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1679. { check_header dev/bktr/ioctl_meteor.h &&
  1680. check_header dev/bktr/ioctl_bt848.h; } ||
  1681. { check_header machine/ioctl_meteor.h &&
  1682. check_header machine/ioctl_bt848.h; } ||
  1683. { check_header dev/video/meteor/ioctl_meteor.h &&
  1684. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1685. check_header dev/ic/bt8xx.h
  1686. check_header sys/soundcard.h
  1687. check_header soundcard.h
  1688. # deal with the X11 frame grabber
  1689. enabled x11grab &&
  1690. check_header X11/Xlib.h &&
  1691. check_header X11/extensions/XShm.h &&
  1692. check_func XOpenDisplay -lX11 &&
  1693. check_func XShmCreateImage -lX11 -lXext
  1694. enabled debug && add_cflags -g"$debuglevel"
  1695. # add some useful compiler flags if supported
  1696. check_cflags -Wdeclaration-after-statement
  1697. check_cflags -Wall
  1698. check_cflags -Wno-switch
  1699. check_cflags -Wdisabled-optimization
  1700. check_cflags -Wpointer-arith
  1701. check_cflags -Wredundant-decls
  1702. check_cflags -Wno-pointer-sign
  1703. check_cflags -Wcast-qual
  1704. check_cflags -Wwrite-strings
  1705. check_cflags -Wtype-limits
  1706. enabled extra_warnings && check_cflags -Winline
  1707. # add some linker flags
  1708. check_ldflags -Wl,--warn-common
  1709. check_ldflags -Wl,--as-needed
  1710. 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'
  1711. check_ldflags -Wl,-Bsymbolic
  1712. if enabled small; then
  1713. check_cflags -Os # not all compilers support -Os
  1714. optimizations="small"
  1715. elif enabled optimizations; then
  1716. if $cc -v 2>&1 | grep -q xlc; then
  1717. add_cflags "-O5"
  1718. add_ldflags "-O5"
  1719. else
  1720. add_cflags "-O3"
  1721. fi
  1722. fi
  1723. check_cflags -fno-math-errno
  1724. check_cflags -fno-signed-zeros
  1725. # add some flags for Intel C Compiler
  1726. if $cc --version 2> /dev/null | grep -q Intel; then
  1727. # Just warnings, no remarks
  1728. check_cflags -w1
  1729. # -wd: Disable following warnings
  1730. # 144, 167, 556: -Wno-pointer-sign
  1731. # 10006: ignoring unknown option -fno-signed-zeros
  1732. # 10156: ignoring option '-W'; no argument required
  1733. check_cflags -wd144,167,556,10006,10156
  1734. # 11030: Warning unknown option --as-needed
  1735. # 10156: ignoring option '-export'; no argument required
  1736. check_ldflags -wd10156,11030
  1737. # Allow to compile with optimizations
  1738. check_ldflags -march=$cpu
  1739. fi
  1740. # PIC flags for shared library objects where they are needed
  1741. if enabled shared; then
  1742. # LIBOBJFLAGS may have already been set in the OS configuration
  1743. if test -z "$LIBOBJFLAGS" ; then
  1744. case "$arch" in
  1745. x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
  1746. esac
  1747. fi
  1748. fi
  1749. if enabled gprof; then
  1750. add_cflags "-p"
  1751. add_ldflags "-p"
  1752. fi
  1753. VHOOKCFLAGS="-fPIC"
  1754. # Find out if the .align argument is a power of two or not.
  1755. if test $asmalign_pot = "unknown"; then
  1756. disable asmalign_pot
  1757. echo '__asm__ (".align 3");' | check_cc && enable asmalign_pot
  1758. fi
  1759. enabled_any $DECODER_LIST && enable decoders
  1760. enabled_any $ENCODER_LIST && enable encoders
  1761. enabled_any $BSF_LIST && enable bsfs
  1762. enabled_any $DEMUXER_LIST && enable demuxers
  1763. enabled_any $MUXER_LIST && enable muxers
  1764. enabled_any $FILTER_LIST && enable filters
  1765. enabled_any $INDEV_LIST && enable demuxers
  1766. enabled_any $OUTDEV_LIST && enable muxers
  1767. enabled_any $PROTOCOL_LIST && enable protocols
  1768. enabled_any $THREADS_LIST && enable threads
  1769. check_deps $CONFIG_LIST \
  1770. $HAVE_LIST \
  1771. $DECODER_LIST \
  1772. $ENCODER_LIST \
  1773. $PARSER_LIST \
  1774. $BSF_LIST \
  1775. $DEMUXER_LIST \
  1776. $MUXER_LIST \
  1777. $FILTER_LIST \
  1778. $INDEV_LIST \
  1779. $OUTDEV_LIST \
  1780. $PROTOCOL_LIST \
  1781. enabled libdc1394 && append pkg_requires "libraw1394"
  1782. enabled libdirac && append pkg_requires "dirac"
  1783. enabled libtheora && append pkg_requires "theora"
  1784. enabled libvorbis && append pkg_requires "vorbisenc"
  1785. echo "install prefix $prefix"
  1786. echo "source path $source_path"
  1787. echo "C compiler $cc"
  1788. echo ".align is power-of-two $asmalign_pot"
  1789. echo "ARCH $arch ($cpu)"
  1790. if test "$build_suffix" != ""; then
  1791. echo "build suffix $build_suffix"
  1792. fi
  1793. if test "$extra_version" != ""; then
  1794. echo "version string suffix $extra_version"
  1795. fi
  1796. echo "big-endian ${bigendian-no}"
  1797. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1798. echo "yasm ${yasm-no}"
  1799. echo "MMX enabled ${mmx-no}"
  1800. echo "CMOV enabled ${cmov-no}"
  1801. echo "CMOV is fast ${fast_cmov-no}"
  1802. echo "EBX available ${ebx_available-no}"
  1803. echo "EBP available ${ebp_available-no}"
  1804. fi
  1805. if test $arch = "armv4l"; then
  1806. echo "ARMv5TE enabled ${armv5te-no}"
  1807. echo "ARMv6 enabled ${armv6-no}"
  1808. echo "ARM VFP enabled ${armvfp-no}"
  1809. echo "IWMMXT enabled ${iwmmxt-no}"
  1810. echo "NEON enabled ${neon-no}"
  1811. fi
  1812. if test $arch = "mips"; then
  1813. echo "MMI enabled ${mmi-no}"
  1814. fi
  1815. if test $arch = "powerpc"; then
  1816. echo "AltiVec enabled ${altivec-no}"
  1817. echo "dcbzl available ${dcbzl-no}"
  1818. fi
  1819. echo "gprof enabled ${gprof-no}"
  1820. echo "debug symbols ${debug-no}"
  1821. echo "strip symbols ${stripping-no}"
  1822. echo "optimizations ${optimizations-no}"
  1823. echo "static ${static-no}"
  1824. echo "shared ${shared-no}"
  1825. echo "postprocessing support ${postproc-no}"
  1826. echo "software scaler enabled ${swscale-no}"
  1827. echo "new filter support ${avfilter-no}"
  1828. echo "filters using lavformat ${avfilter_lavf-no}"
  1829. echo "video hooking ${vhook-no}"
  1830. if enabled vhook; then
  1831. echo "Imlib2 support ${imlib2-no}"
  1832. echo "FreeType support ${freetype2-no}"
  1833. fi
  1834. echo "network support ${network-no}"
  1835. if enabled network; then
  1836. echo "IPv6 support ${ipv6-no}"
  1837. fi
  1838. echo "threading support ${thread_type-no}"
  1839. echo "SDL support ${sdl-no}"
  1840. if enabled sdl_too_old; then
  1841. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1842. fi
  1843. echo "Sun medialib support ${mlib-no}"
  1844. echo "AVISynth enabled ${avisynth-no}"
  1845. echo "libamr-nb support ${libamr_nb-no}"
  1846. echo "libamr-wb support ${libamr_wb-no}"
  1847. echo "libdc1394 support ${libdc1394-no}"
  1848. echo "libdirac enabled ${libdirac-no}"
  1849. echo "libfaac enabled ${libfaac-no}"
  1850. echo "libfaad enabled ${libfaad-no}"
  1851. echo "libfaad dlopened ${libfaadbin-no}"
  1852. echo "libgsm enabled ${libgsm-no}"
  1853. echo "libmp3lame enabled ${libmp3lame-no}"
  1854. echo "libnut enabled ${libnut-no}"
  1855. echo "libschroedinger enabled ${libschroedinger-no}"
  1856. echo "libspeex enabled ${libspeex-no}"
  1857. echo "libtheora enabled ${libtheora-no}"
  1858. echo "libvorbis enabled ${libvorbis-no}"
  1859. echo "libx264 enabled ${libx264-no}"
  1860. echo "libxvid enabled ${libxvid-no}"
  1861. echo "zlib enabled ${zlib-no}"
  1862. echo "bzlib enabled ${bzlib-no}"
  1863. echo
  1864. for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
  1865. echo "Enabled ${type}s:"
  1866. eval list=\$$(toupper $type)_LIST
  1867. for part in $list; do
  1868. enabled $part && echo ${part%_*}
  1869. done | sort | pr -3 -t
  1870. echo
  1871. done
  1872. license="LGPL"
  1873. if enabled nonfree; then
  1874. license="unredistributable"
  1875. elif enabled gpl; then
  1876. license="GPL"
  1877. fi
  1878. echo "License: $license"
  1879. echo "Creating config.mak and config.h..."
  1880. echo "# Automatically generated by configure - do not modify!" > config.mak
  1881. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1882. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  1883. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  1884. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1885. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  1886. echo "prefix=$prefix" >> config.mak
  1887. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  1888. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  1889. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  1890. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  1891. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  1892. echo "CC=$cc" >> config.mak
  1893. echo "YASM=$yasmexe" >> config.mak
  1894. echo "AR=$ar" >> config.mak
  1895. echo "RANLIB=$ranlib" >> config.mak
  1896. echo "LN_S=$ln_s" >> config.mak
  1897. enabled stripping &&
  1898. echo "STRIP=$strip" >> config.mak ||
  1899. echo "STRIP=echo ignoring strip" >> config.mak
  1900. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1901. echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
  1902. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1903. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1904. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1905. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  1906. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1907. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1908. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1909. echo "BUILD_STATIC=$static" >> config.mak
  1910. echo "BUILDSUF=$build_suffix" >> config.mak
  1911. echo "FULLNAME=$FULLNAME" >> config.mak
  1912. echo "LIBPREF=$LIBPREF" >> config.mak
  1913. echo "LIBSUF=$LIBSUF" >> config.mak
  1914. echo "LIBNAME=$LIBNAME" >> config.mak
  1915. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1916. echo "SLIBSUF=$SLIBSUF" >> config.mak
  1917. echo "EXESUF=$EXESUF" >> config.mak
  1918. echo "EXTRA_VERSION=$extra_version" >> config.mak
  1919. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  1920. if enabled bigendian; then
  1921. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1922. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1923. fi
  1924. if enabled sdl; then
  1925. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1926. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1927. fi
  1928. if enabled texi2html; then
  1929. echo "BUILD_DOC=yes" >> config.mak
  1930. fi
  1931. get_version(){
  1932. name=$1
  1933. file=$source_path/$2
  1934. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  1935. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  1936. lcname=$(tolower $name)
  1937. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  1938. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  1939. }
  1940. get_version LIBSWSCALE libswscale/swscale.h
  1941. get_version LIBPOSTPROC libpostproc/postprocess.h
  1942. get_version LIBAVCODEC libavcodec/avcodec.h
  1943. get_version LIBAVDEVICE libavdevice/avdevice.h
  1944. get_version LIBAVFORMAT libavformat/avformat.h
  1945. get_version LIBAVUTIL libavutil/avutil.h
  1946. get_version LIBAVFILTER libavfilter/avfilter.h
  1947. if enabled shared; then
  1948. echo "BUILD_SHARED=yes" >> config.mak
  1949. echo "PIC=-fPIC -DPIC" >> config.mak
  1950. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  1951. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1952. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1953. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1954. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  1955. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1956. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1957. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  1958. fi
  1959. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1960. echo "EXTRALIBS=$extralibs" >> config.mak
  1961. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  1962. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1963. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  1964. $DECODER_LIST \
  1965. $ENCODER_LIST \
  1966. $PARSER_LIST \
  1967. $BSF_LIST \
  1968. $DEMUXER_LIST \
  1969. $MUXER_LIST \
  1970. $FILTER_LIST \
  1971. $PROTOCOL_LIST \
  1972. $INDEV_LIST \
  1973. $OUTDEV_LIST \
  1974. echo "#define restrict $_restrict" >> $TMPH
  1975. if enabled small; then
  1976. echo "#define av_always_inline" >> $TMPH
  1977. fi
  1978. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1979. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1980. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1981. # Apparently it's not possible to portably echo a backslash.
  1982. enabled asmalign_pot &&
  1983. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  1984. printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
  1985. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  1986. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  1987. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  1988. cmp -s $TMPH config.h &&
  1989. echo "config.h is unchanged" ||
  1990. mv -f $TMPH config.h
  1991. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  1992. # build tree in object directory if source path is different from current one
  1993. if enabled source_path_used; then
  1994. DIRS="\
  1995. doc \
  1996. libavcodec \
  1997. libavcodec/alpha \
  1998. libavcodec/armv4l \
  1999. libavcodec/bfin \
  2000. libavcodec/i386 \
  2001. libavcodec/mlib \
  2002. libavcodec/ppc \
  2003. libavcodec/sh4 \
  2004. libavcodec/sparc \
  2005. libavdevice \
  2006. libavfilter \
  2007. libavformat \
  2008. libavutil \
  2009. libpostproc \
  2010. libswscale \
  2011. tests \
  2012. tools \
  2013. vhook \
  2014. "
  2015. FILES="\
  2016. Makefile \
  2017. common.mak \
  2018. subdir.mak \
  2019. doc/texi2pod.pl \
  2020. libavcodec/Makefile \
  2021. libavdevice/Makefile \
  2022. libavfilter/Makefile \
  2023. libavformat/Makefile \
  2024. libavutil/Makefile \
  2025. libpostproc/Makefile \
  2026. libswscale/Makefile \
  2027. "
  2028. for dir in $DIRS ; do
  2029. mkdir -p $dir
  2030. done
  2031. for f in $FILES ; do
  2032. $ln_s "$source_path/$f" $f
  2033. done
  2034. fi
  2035. # build pkg-config files
  2036. pkgconfig_generate(){
  2037. name=$1
  2038. shortname=${name#lib}
  2039. comment=$2
  2040. version=$3
  2041. libs=$4
  2042. requires=$5
  2043. cat <<EOF > $name/$name.pc
  2044. prefix=$prefix
  2045. exec_prefix=\${prefix}
  2046. libdir=$libdir
  2047. includedir=$incdir
  2048. Name: $name
  2049. Description: $comment
  2050. Version: $version
  2051. Requires: $(disabled shared && echo $requires)
  2052. Requires.private: $(enabled shared && echo $requires)
  2053. Conflicts:
  2054. Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
  2055. Libs.private: $(enabled shared && echo $libs)
  2056. Cflags: -I\${includedir}
  2057. EOF
  2058. cat <<EOF > $name/$name-uninstalled.pc
  2059. prefix=
  2060. exec_prefix=
  2061. libdir=\${pcfiledir}
  2062. includedir=${source_path}
  2063. Name: $name
  2064. Description: $comment
  2065. Version: $version
  2066. Requires: $requires
  2067. Conflicts:
  2068. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2069. Cflags: -I\${includedir}
  2070. EOF
  2071. }
  2072. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2073. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2074. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2075. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
  2076. enabled avfilter &&
  2077. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2078. enabled postproc &&
  2079. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2080. if enabled swscale; then
  2081. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  2082. else
  2083. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2084. apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
  2085. fi