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.

2298 lines
66KB

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