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.

2300 lines
66KB

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