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.

2375 lines
68KB

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