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.

2291 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. check_foo_config(){
  566. cfg=$1
  567. pkg=$2
  568. header=$3
  569. func=$4
  570. shift 4
  571. disable $cfg
  572. check_cmd ${pkg}-config --version
  573. err=$?
  574. if test "$err" = 0; then
  575. temp_cflags `${pkg}-config --cflags`
  576. temp_extralibs `${pkg}-config --libs`
  577. check_lib "$@" $header $func && enable $cfg
  578. fi
  579. return $err
  580. }
  581. apply(){
  582. file=$1
  583. shift
  584. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  585. }
  586. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  587. # system-dependent things.
  588. COMPONENT_LIST="
  589. bsfs
  590. decoders
  591. demuxers
  592. encoders
  593. filters
  594. indevs
  595. muxers
  596. outdevs
  597. parsers
  598. protocols
  599. "
  600. CONFIG_LIST="
  601. $COMPONENT_LIST
  602. avfilter
  603. avfilter_lavf
  604. avisynth
  605. beos_netserver
  606. bzlib
  607. ffmpeg
  608. ffplay
  609. ffserver
  610. gpl
  611. gprof
  612. gray
  613. hardcoded_tables
  614. ipv6
  615. libamr_nb
  616. libamr_wb
  617. libdc1394
  618. libdirac
  619. libfaac
  620. libfaad
  621. libfaadbin
  622. libgsm
  623. libmp3lame
  624. libnut
  625. libschroedinger
  626. libtheora
  627. libvorbis
  628. libx264
  629. libxvid
  630. memalign_hack
  631. mlib
  632. mpegaudio_hp
  633. network
  634. nonfree
  635. postproc
  636. powerpc_perf
  637. small
  638. swscale
  639. vhook
  640. x11grab
  641. zlib
  642. "
  643. THREADS_LIST='
  644. beosthreads
  645. os2threads
  646. pthreads
  647. w32threads
  648. '
  649. ARCH_LIST='
  650. alpha
  651. armv4l
  652. bfin
  653. ia64
  654. m68k
  655. mips
  656. parisc
  657. powerpc
  658. s390
  659. sh4
  660. sparc
  661. sparc64
  662. x86
  663. x86_32
  664. x86_64
  665. '
  666. ARCH_EXT_LIST='
  667. altivec
  668. armv5te
  669. armv6
  670. armvfp
  671. iwmmxt
  672. mmi
  673. mmx
  674. mmx2
  675. neon
  676. ssse3
  677. vis
  678. '
  679. HAVE_LIST="
  680. $ARCH_EXT_LIST
  681. $THREADS_LIST
  682. altivec_h
  683. arpa_inet_h
  684. bswap
  685. closesocket
  686. cmov
  687. conio_h
  688. dcbzl
  689. dev_bktr_ioctl_bt848_h
  690. dev_bktr_ioctl_meteor_h
  691. dev_ic_bt8xx_h
  692. dev_video_meteor_ioctl_meteor_h
  693. dev_video_bktr_ioctl_bt848_h
  694. dlfcn_h
  695. dlopen
  696. dos_paths
  697. ebp_available
  698. ebx_available
  699. fast_64bit
  700. fast_cmov
  701. fast_unaligned
  702. fork
  703. freetype2
  704. gethrtime
  705. GetProcessTimes
  706. getrusage
  707. imlib2
  708. inet_aton
  709. inline_asm
  710. libdc1394_1
  711. libdc1394_2
  712. llrint
  713. lrint
  714. lrintf
  715. machine_ioctl_bt848_h
  716. machine_ioctl_meteor_h
  717. malloc_h
  718. memalign
  719. mkstemp
  720. pld
  721. ppc64
  722. round
  723. roundf
  724. sdl
  725. sdl_video_size
  726. socklen_t
  727. soundcard_h
  728. poll_h
  729. sys_mman_h
  730. sys_resource_h
  731. sys_select_h
  732. sys_soundcard_h
  733. sys_videoio_h
  734. termios_h
  735. threads
  736. winsock2_h
  737. yasm
  738. "
  739. CMDLINE_SELECT="
  740. $ARCH_EXT_LIST
  741. $CONFIG_LIST
  742. $THREADS_LIST
  743. cross_compile
  744. debug
  745. extra_warnings
  746. logging
  747. optimizations
  748. shared
  749. static
  750. stripping
  751. "
  752. PATHS_LIST='
  753. bindir
  754. incdir
  755. libdir
  756. mandir
  757. prefix
  758. shlibdir
  759. '
  760. CMDLINE_SET="
  761. $PATHS_LIST
  762. arch
  763. build_suffix
  764. cc
  765. cpu
  766. cross_prefix
  767. extra_version
  768. logfile
  769. source_path
  770. target_os
  771. "
  772. # code dependency declarations
  773. # architecture extensions
  774. altivec_deps="powerpc"
  775. armv5te_deps="armv4l"
  776. armv6_deps="armv4l"
  777. armvfp_deps="armv4l"
  778. iwmmxt_deps="armv4l"
  779. mmi_deps="mips"
  780. mmx_deps="x86"
  781. mmx2_deps="x86 mmx"
  782. neon_deps="armv4l"
  783. ssse3_deps="x86"
  784. vis_deps="sparc"
  785. # decoders / encoders
  786. ac3_decoder_deps="gpl"
  787. dxa_decoder_deps="zlib"
  788. eac3_decoder_deps="gpl"
  789. flashsv_decoder_deps="zlib"
  790. flashsv_encoder_deps="zlib"
  791. mlp_decoder_deps="mlp_parser"
  792. mpeg_xvmc_decoder_deps="xvmc"
  793. png_decoder_deps="zlib"
  794. png_encoder_deps="zlib"
  795. zmbv_decoder_deps="zlib"
  796. zmbv_encoder_deps="zlib"
  797. # external libraries
  798. libamr_nb_decoder_deps="libamr_nb"
  799. libamr_nb_encoder_deps="libamr_nb"
  800. libamr_wb_decoder_deps="libamr_wb"
  801. libamr_wb_encoder_deps="libamr_wb"
  802. libdirac_decoder_deps="libdirac !libschroedinger"
  803. libdirac_encoder_deps="libdirac"
  804. libfaac_encoder_deps="libfaac"
  805. libfaad_decoder_deps="libfaad"
  806. libfaadbin_decoder_extralibs='$ldl'
  807. libgsm_decoder_deps="libgsm"
  808. libgsm_encoder_deps="libgsm"
  809. libgsm_ms_decoder_deps="libgsm"
  810. libgsm_ms_encoder_deps="libgsm"
  811. libmp3lame_encoder_deps="libmp3lame"
  812. libschroedinger_decoder_deps="libschroedinger"
  813. libschroedinger_encoder_deps="libschroedinger"
  814. libtheora_encoder_deps="libtheora"
  815. libvorbis_encoder_deps="libvorbis"
  816. libx264_encoder_deps="libx264"
  817. libxvid_encoder_deps="libxvid"
  818. mpeg4aac_decoder_deps="libfaad"
  819. # demuxers / muxers
  820. ac3_demuxer_deps="ac3_parser"
  821. audio_beos_demuxer_deps="audio_beos"
  822. audio_beos_demuxer_extralibs="-lmedia -lbe"
  823. audio_beos_muxer_deps="audio_beos"
  824. audio_beos_muxer_extralibs="-lmedia -lbe"
  825. avisynth_demuxer_deps="avisynth"
  826. bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  827. dirac_demuxer_deps="dirac_parser"
  828. dv1394_demuxer_deps="dv1394 dv_demuxer"
  829. libdc1394_demuxer_deps="libdc1394"
  830. libnut_demuxer_deps="libnut"
  831. libnut_muxer_deps="libnut"
  832. mp3_demuxer_deps="mpegaudio_parser"
  833. oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
  834. oss_muxer_deps_any="soundcard_h sys_soundcard_h"
  835. redir_demuxer_deps="network"
  836. rtp_muxer_deps="network rtp_protocol"
  837. rtsp_demuxer_deps="sdp_demuxer"
  838. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  839. v4l_demuxer_deps="linux_videodev_h"
  840. v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
  841. vfwcap_demuxer_deps="capCreateCaptureWindow"
  842. vfwcap_demuxer_extralibs="-lvfw32"
  843. x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
  844. x11_grab_device_demuxer_extralibs="-lX11 -lXext"
  845. # protocols
  846. http_protocol_deps="network"
  847. rtp_protocol_deps="udp_protocol"
  848. tcp_protocol_deps="network"
  849. udp_protocol_deps="network"
  850. # filters
  851. movie_filter_deps="avfilter_lavf"
  852. # programs
  853. ffplay_deps="sdl"
  854. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  855. ffserver_extralibs='$ldl'
  856. vhook_extralibs='$ldl'
  857. # default parameters
  858. logfile="config.err"
  859. # installation paths
  860. prefix_default="/usr/local"
  861. bindir_default='${prefix}/bin'
  862. incdir_default='${prefix}/include'
  863. libdir_default='${prefix}/lib'
  864. mandir_default='${prefix}/share/man'
  865. shlibdir_default="$libdir_default"
  866. # toolchain
  867. cc="gcc"
  868. yasmexe="yasm"
  869. ar="ar"
  870. nm="nm"
  871. ranlib="ranlib"
  872. strip="strip"
  873. asmalign_pot="unknown"
  874. ln_s="ln -sf"
  875. objformat="elf"
  876. # machine
  877. arch=`uname -m`
  878. cpu="generic"
  879. # OS
  880. target_os=$(tolower $(uname -s))
  881. # libraries
  882. enable bzlib
  883. enable zlib
  884. # configurable options
  885. enable debug
  886. enable ffmpeg
  887. enable ffplay
  888. enable ffserver
  889. enable ipv6
  890. enable mpegaudio_hp
  891. enable network
  892. enable optimizations
  893. enable protocols
  894. enable static
  895. enable stripping
  896. vhook="default"
  897. # build settings
  898. add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  899. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  900. VHOOKSHFLAGS='$(SHFLAGS)'
  901. FFSERVERLDFLAGS=-Wl,-E
  902. LIBPREF="lib"
  903. LIBSUF=".a"
  904. FULLNAME='$(NAME)$(BUILDSUF)'
  905. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  906. SLIBPREF="lib"
  907. SLIBSUF=".so"
  908. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  909. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  910. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  911. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  912. # gcc stupidly only outputs the basename of targets with -MM, but we need the
  913. # full relative path for objects in subdirectories for non-recursive Make.
  914. DEPEND_CMD='$(CC) $(CFLAGS) -MM -MG $< | sed -e "/^\#.*/d" -e "1s,^,$(@D)/," -e "s,\\([[:space:]]\\)\\(version\\.h\\),\\1\$$(BUILD_ROOT_REL)/\\2,"'
  915. # find source path
  916. source_path="`dirname \"$0\"`"
  917. enable source_path_used
  918. if test -z "$source_path" -o "$source_path" = "." ; then
  919. source_path="`pwd`"
  920. disable source_path_used
  921. else
  922. source_path="`cd \"$source_path\"; pwd`"
  923. echo "$source_path" | grep -q '[[:blank:]]' &&
  924. die "Out of tree builds are impossible with whitespace in source path."
  925. fi
  926. FFMPEG_CONFIGURATION="$@"
  927. find_things(){
  928. thing=$1
  929. pattern=$2
  930. file=$source_path/$3
  931. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  932. }
  933. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  934. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  935. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  936. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  937. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  938. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  939. OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
  940. INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
  941. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  942. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  943. enable $ARCH_EXT_LIST \
  944. $DECODER_LIST \
  945. $ENCODER_LIST \
  946. $PARSER_LIST \
  947. $BSF_LIST \
  948. $DEMUXER_LIST \
  949. $MUXER_LIST \
  950. $FILTER_LIST \
  951. $PROTOCOL_LIST \
  952. $INDEV_LIST \
  953. $OUTDEV_LIST \
  954. die_unknown(){
  955. echo "Unknown option \"$1\"."
  956. echo "See $0 --help for available options."
  957. exit 1
  958. }
  959. show_list() {
  960. suffix=_$1
  961. shift
  962. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  963. exit 0
  964. }
  965. for opt do
  966. optval="${opt#*=}"
  967. case "$opt" in
  968. --extra-cflags=*) add_cflags "$optval"
  969. ;;
  970. --extra-ldflags=*) add_ldflags "$optval"
  971. ;;
  972. --extra-libs=*) add_extralibs "$optval"
  973. ;;
  974. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  975. ;;
  976. --enable-debug=*) debuglevel="$optval"
  977. ;;
  978. --enable-*=*|--disable-*=*)
  979. eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
  980. case "$thing" in
  981. encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
  982. *) die_unknown "$opt" ;;
  983. esac
  984. ;;
  985. --enable-?*|--disable-?*)
  986. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  987. if is_in $option $COMPONENT_LIST; then
  988. eval $action \$$(toupper ${option%s})_LIST
  989. elif is_in $option $CMDLINE_SELECT; then
  990. $action $option
  991. else
  992. die_unknown $opt
  993. fi
  994. ;;
  995. --list-*)
  996. NAME="${opt#--list-}"
  997. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  998. NAME=${NAME%s}
  999. eval show_list $NAME \$$(toupper $NAME)_LIST
  1000. ;;
  1001. --help|-h) show_help
  1002. ;;
  1003. *)
  1004. optname="${opt%=*}"
  1005. optname="${optname#--}"
  1006. optname=$(echo "$optname" | sed 's/-/_/g')
  1007. is_in $optname $CMDLINE_SET || die_unknown $opt
  1008. eval $optname='$optval'
  1009. ;;
  1010. esac
  1011. done
  1012. disabled logging && logfile=/dev/null
  1013. echo "# $0 $@" > $logfile
  1014. set >> $logfile
  1015. cc="${cross_prefix}${cc}"
  1016. yasmexe="${cross_prefix}${yasmexe}"
  1017. ar="${cross_prefix}${ar}"
  1018. nm="${cross_prefix}${nm}"
  1019. ranlib="${cross_prefix}${ranlib}"
  1020. strip="${cross_prefix}${strip}"
  1021. # set temporary file name
  1022. if test ! -z "$TMPDIR" ; then
  1023. TMPDIR1="${TMPDIR}"
  1024. elif test ! -z "$TEMPDIR" ; then
  1025. TMPDIR1="${TEMPDIR}"
  1026. else
  1027. TMPDIR1="/tmp"
  1028. fi
  1029. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  1030. TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
  1031. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  1032. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  1033. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  1034. TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
  1035. check_cflags -std=c99
  1036. case "$arch" in
  1037. i386|i486|i586|i686|i86pc|BePC)
  1038. arch="x86_32"
  1039. enable fast_unaligned
  1040. ;;
  1041. x86_64|amd64)
  1042. arch="x86_32"
  1043. enable fast_unaligned
  1044. check_cc <<EOF && enable fast_64bit && arch="x86_64"
  1045. int test[sizeof(char*) - 7];
  1046. EOF
  1047. ;;
  1048. # armv4l is a subset of armv[567]*l
  1049. arm|armv[4567]*l)
  1050. arch="armv4l"
  1051. ;;
  1052. alpha)
  1053. arch="alpha"
  1054. enable fast_64bit
  1055. ;;
  1056. "Power Macintosh"|ppc|powerpc)
  1057. arch="powerpc"
  1058. enable fast_unaligned
  1059. ;;
  1060. ppc64)
  1061. arch="powerpc"
  1062. enable fast_64bit
  1063. enable fast_unaligned
  1064. ;;
  1065. mips|mipsel|IP*)
  1066. arch="mips"
  1067. ;;
  1068. sun4u|sparc64)
  1069. arch="sparc64"
  1070. enable fast_64bit
  1071. ;;
  1072. sparc)
  1073. arch="sparc"
  1074. ;;
  1075. sh4)
  1076. arch="sh4"
  1077. ;;
  1078. parisc)
  1079. arch="parisc"
  1080. ;;
  1081. parisc64)
  1082. arch="parisc"
  1083. enable fast_64bit
  1084. ;;
  1085. s390|s390x)
  1086. arch="s390"
  1087. ;;
  1088. m68k)
  1089. arch="m68k"
  1090. ;;
  1091. ia64)
  1092. arch="ia64"
  1093. enable fast_64bit
  1094. ;;
  1095. bfin)
  1096. arch="bfin"
  1097. ;;
  1098. *)
  1099. arch="unknown"
  1100. ;;
  1101. esac
  1102. enable $arch
  1103. enabled_any x86_32 x86_64 && enable x86
  1104. enabled sparc64 && enable sparc
  1105. # OS specific
  1106. case $target_os in
  1107. beos|haiku|zeta)
  1108. prefix_default="$HOME/config"
  1109. # helps building libavcodec
  1110. add_cflags "-DPIC -fomit-frame-pointer"
  1111. # 3 gcc releases known for BeOS, each with ugly bugs
  1112. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1113. case "$gcc_version" in
  1114. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1115. disable mmx
  1116. ;;
  1117. *20010315*) echo "BeBits gcc"
  1118. add_cflags "-fno-expensive-optimizations"
  1119. ;;
  1120. esac
  1121. SHFLAGS=-nostart
  1122. # enable BeOS things
  1123. enable audio_beos
  1124. # no need for libm, but the inet stuff
  1125. # Check for BONE
  1126. # XXX: actually should check for NOT net_server
  1127. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  1128. network_extralibs="-lbind -lsocket"
  1129. else
  1130. enable beos_netserver
  1131. network_extralibs="-lnet"
  1132. fi ;;
  1133. sunos)
  1134. FFSERVERLDFLAGS=""
  1135. SHFLAGS='-shared -Wl,-h,$$(@F)'
  1136. network_extralibs="-lsocket -lnsl"
  1137. ;;
  1138. netbsd)
  1139. oss_demuxer_extralibs="-lossaudio"
  1140. oss_muxer_extralibs="-lossaudio"
  1141. ;;
  1142. openbsd)
  1143. disable need_memalign
  1144. LIBOBJFLAGS='$(PIC)'
  1145. SHFLAGS='-shared'
  1146. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
  1147. SLIBNAME_WITH_VERSION='$(SLIBNAME)'
  1148. SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
  1149. oss_demuxer_extralibs="-lossaudio"
  1150. oss_muxer_extralibs="-lossaudio"
  1151. ;;
  1152. freebsd)
  1153. disable need_memalign
  1154. ;;
  1155. bsd/os)
  1156. osextralibs="-lpoll -lgnugetopt"
  1157. strip="strip -d"
  1158. ;;
  1159. darwin)
  1160. disable need_memalign
  1161. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1162. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
  1163. strip="strip -x"
  1164. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1165. SLIBSUF=".dylib"
  1166. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1167. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1168. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1169. objformat="macho"
  1170. enabled x86_64 && objformat="macho64"
  1171. ;;
  1172. mingw32*)
  1173. target_os=mingw32
  1174. LIBTARGET=i386
  1175. if test $arch = x86_64; then
  1176. disable need_memalign
  1177. LIBTARGET=x64
  1178. fi
  1179. shlibdir_default="$bindir_default"
  1180. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1181. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1182. if enabled swscale; then
  1183. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1184. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1185. fi
  1186. disable ffserver
  1187. SLIBPREF=""
  1188. SLIBSUF=".dll"
  1189. EXESUF=".exe"
  1190. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1191. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1192. SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1193. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1194. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
  1195. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1196. SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  1197. objformat="win32"
  1198. enable dos_paths
  1199. ;;
  1200. cygwin*)
  1201. target_os=cygwin
  1202. shlibdir_default="$bindir_default"
  1203. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1204. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1205. if enabled swscale; then
  1206. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1207. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1208. fi
  1209. EXESUF=".exe"
  1210. SLIBPREF="cyg"
  1211. SLIBSUF=".dll"
  1212. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1213. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1214. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1215. objformat="win32"
  1216. enable dos_paths
  1217. ;;
  1218. *-dos|freedos|opendos)
  1219. disable ffplay ffserver vhook
  1220. disable $INDEV_LIST $OUTDEV_LIST
  1221. network_extralibs="-lsocket"
  1222. EXESUF=".exe"
  1223. objformat="win32"
  1224. enable dos_paths
  1225. ;;
  1226. linux)
  1227. enable dv1394
  1228. ;;
  1229. irix*)
  1230. target_os=irix
  1231. ranlib="echo ignoring ranlib"
  1232. ;;
  1233. os/2*)
  1234. strip="lxlite"
  1235. ln_s="cp -f"
  1236. EXESUF=".exe"
  1237. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1238. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1239. FFSERVERLDFLAGS=""
  1240. LIBSUF="_s.a"
  1241. SLIBPREF=""
  1242. SLIBSUF=".dll"
  1243. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1244. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1245. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1246. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1247. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1248. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1249. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1250. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1251. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1252. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1253. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1254. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1255. disable vhook
  1256. enable dos_paths
  1257. ;;
  1258. interix)
  1259. disable vhook
  1260. ;;
  1261. *)
  1262. target_os="${target_os}-UNKNOWN"
  1263. ;;
  1264. esac
  1265. set_default $PATHS_LIST
  1266. add_extralibs $osextralibs
  1267. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1268. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1269. test -n "$cross_prefix" && enable cross_compile
  1270. # we need to build at least one lib type
  1271. if ! enabled_any static shared; then
  1272. cat <<EOF
  1273. At least one library type must be built.
  1274. Specify --enable-static to build the static libraries or --enable-shared to
  1275. build the shared libraries as well. To only build the shared libraries specify
  1276. --disable-static in addition to --enable-shared.
  1277. EOF
  1278. exit 1;
  1279. fi
  1280. disabled static && LIBNAME=""
  1281. if enabled_any libfaad libfaadbin ; then
  1282. if check_header faad.h; then
  1283. check_cc <<EOF
  1284. #include <faad.h>
  1285. #ifndef FAAD2_VERSION
  1286. ok faad1
  1287. #endif
  1288. int main(void) { return 0; }
  1289. EOF
  1290. test $? = 0 && enable libfaad2
  1291. else
  1292. die "FAAD test failed."
  1293. fi
  1294. fi
  1295. if ! enabled gpl; then
  1296. die_gpl_disabled(){
  1297. name=$1
  1298. shift
  1299. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1300. }
  1301. die_gpl_disabled "The Postprocessing code" postproc
  1302. die_gpl_disabled "libx264" libx264
  1303. die_gpl_disabled "libxvidcore" libxvid
  1304. die_gpl_disabled "FAAD2" libfaad2
  1305. die_gpl_disabled "The X11 grabber" x11grab
  1306. die_gpl_disabled "The software scaler" swscale
  1307. fi
  1308. if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
  1309. die "libamr is nonfree and --enable-nonfree is not specified."
  1310. fi
  1311. check_deps $ARCH_EXT_LIST
  1312. test -z "$need_memalign" && need_memalign="$mmx"
  1313. #Darwin CC versions
  1314. if test $target_os = darwin; then
  1315. if $cc -v 2>&1 | grep -q xlc; then
  1316. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1317. else
  1318. add_cflags "-pipe"
  1319. check_cflags "-force_cpusubtype_ALL"
  1320. check_cflags "-Wno-sign-compare"
  1321. enabled shared || check_cflags -mdynamic-no-pic
  1322. fi
  1323. fi
  1324. disabled optimizations || check_cflags -fomit-frame-pointer
  1325. # Add processor-specific flags
  1326. if test $cpu != "generic"; then
  1327. warn_altivec(){
  1328. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1329. }
  1330. case $cpu in
  1331. 601|ppc601|PowerPC601)
  1332. add_cflags "-mcpu=601"
  1333. warn_altivec enabled PPC601
  1334. ;;
  1335. 603*|ppc603*|PowerPC603*)
  1336. add_cflags "-mcpu=603"
  1337. warn_altivec enabled PPC603
  1338. ;;
  1339. 604*|ppc604*|PowerPC604*)
  1340. add_cflags "-mcpu=604"
  1341. warn_altivec enabled PPC604
  1342. ;;
  1343. G3|g3|75*|ppc75*|PowerPC75*)
  1344. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1345. warn_altivec enabled PPC75x
  1346. ;;
  1347. G4|g4|745*|ppc745*|PowerPC745*)
  1348. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1349. warn_altivec disabled PPC745x
  1350. ;;
  1351. 74*|ppc74*|PowerPC74*)
  1352. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1353. warn_altivec disabled PPC74xx
  1354. ;;
  1355. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1356. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1357. warn_altivec disabled PPC970
  1358. enable ppc64
  1359. ;;
  1360. Cell|CELL|cell)
  1361. add_cflags "-mcpu=cell"
  1362. warn_altivec disabled Cell
  1363. enable ppc64
  1364. ;;
  1365. # targets that do NOT support conditional mov (cmov)
  1366. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1367. add_cflags "-march=$cpu"
  1368. disable cmov
  1369. ;;
  1370. # targets that do support conditional mov (cmov)
  1371. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1372. add_cflags "-march=$cpu"
  1373. enable cmov
  1374. enable fast_cmov
  1375. ;;
  1376. # targets that do support conditional mov but on which it's slow
  1377. pentium4|pentium4m|prescott|nocona)
  1378. add_cflags "-march=$cpu"
  1379. enable cmov
  1380. disable fast_cmov
  1381. ;;
  1382. sparc64)
  1383. add_cflags "-mcpu=v9"
  1384. ;;
  1385. arm11*|cortex*)
  1386. add_cflags "-mcpu=$cpu"
  1387. enable fast_unaligned
  1388. ;;
  1389. arm*)
  1390. add_cflags "-mcpu=$cpu"
  1391. ;;
  1392. *)
  1393. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1394. ;;
  1395. esac
  1396. fi
  1397. # make sure we can execute files in $TMPDIR
  1398. cat > $TMPSH 2>> $logfile <<EOF
  1399. #! /bin/sh
  1400. EOF
  1401. chmod +x $TMPSH >> $logfile 2>&1
  1402. if ! $TMPSH >> $logfile 2>&1; then
  1403. cat <<EOF
  1404. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1405. variable to another directory and make sure that $TMPDIR1 is not mounted
  1406. noexec.
  1407. EOF
  1408. die "Sanity test failed."
  1409. fi
  1410. rm $TMPSH
  1411. # compiler sanity check
  1412. check_exec <<EOF
  1413. int main(void){ return 0; }
  1414. EOF
  1415. if test "$?" != 0; then
  1416. echo "$cc is unable to create an executable file."
  1417. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1418. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1419. echo "Only do this if you know what cross compiling means."
  1420. fi
  1421. die "C compiler test failed."
  1422. fi
  1423. check_cc <<EOF || die "Symbol mangling check failed."
  1424. int ff_extern;
  1425. EOF
  1426. sym=$($nm -P -g $TMPO | grep ff_extern)
  1427. extern_prefix=${sym%%ff_extern*}
  1428. check_asm inline_asm '""'
  1429. if enabled x86; then
  1430. # check whether EBP is available on x86
  1431. # As 'i' is stored on the stack, this program will crash
  1432. # if the base pointer is used to access it because the
  1433. # base pointer is cleared in the inline assembly code.
  1434. check_exec_crash <<EOF && enable ebp_available
  1435. volatile int i=0;
  1436. __asm__ volatile (
  1437. "xorl %%ebp, %%ebp"
  1438. ::: "%ebp");
  1439. return i;
  1440. EOF
  1441. # check wether EBX is available on x86
  1442. check_asm ebx_available '"":::"%ebx"'
  1443. # check whether binutils is new enough to compile SSSE3/MMX2
  1444. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1445. enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
  1446. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1447. YASMFLAGS="-f $objformat -DARCH_$(toupper $arch)"
  1448. enabled x86_64 && append YASMFLAGS "-m amd64"
  1449. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  1450. case "$objformat" in
  1451. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  1452. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  1453. *) append YASMFLAGS "-DPREFIX" ;;
  1454. esac
  1455. check_yasm "pabsw xmm0, xmm0" && enable yasm
  1456. fi
  1457. # check for assembler specific support
  1458. if test $arch = "powerpc"; then
  1459. check_asm dcbzl '"dcbzl 0, 1"'
  1460. fi
  1461. # check for SIMD availability
  1462. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1463. if enabled altivec; then
  1464. check_cflags -maltivec -mabi=altivec &&
  1465. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1466. check_cflags -faltivec
  1467. # check if our compiler supports Motorola AltiVec C API
  1468. check_cc <<EOF || disable altivec
  1469. $inc_altivec_h
  1470. int main(void) {
  1471. vector signed int v1, v2, v3;
  1472. v1 = vec_add(v2,v3);
  1473. return 0;
  1474. }
  1475. EOF
  1476. # check if our compiler supports braces for vector declarations
  1477. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1478. $inc_altivec_h
  1479. int main (void) { (vector int) {1}; return 0; }
  1480. EOF
  1481. fi
  1482. # We have to check if pld is a nop and disable it.
  1483. enabled armv4l && check_asm pld '"pld [r0]"'
  1484. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1485. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1486. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1487. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1488. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1489. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1490. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1491. enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
  1492. # ---
  1493. # big/little-endian test
  1494. check_cc <<EOF || die "endian test failed"
  1495. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1496. EOF
  1497. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1498. # ---
  1499. # check availability of some header files
  1500. if check_func dlopen; then
  1501. ldl=
  1502. elif check_func dlopen -ldl; then
  1503. ldl=-ldl
  1504. fi
  1505. check_func fork
  1506. check_func gethrtime
  1507. check_func getrusage
  1508. check_func inet_aton $network_extralibs
  1509. check_func memalign
  1510. check_func mkstemp
  1511. check_func_headers windows.h GetProcessTimes
  1512. check_header conio.h
  1513. check_header dlfcn.h
  1514. check_header malloc.h
  1515. check_header poll.h
  1516. check_header sys/mman.h
  1517. check_header sys/resource.h
  1518. check_header sys/select.h
  1519. check_header termios.h
  1520. if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
  1521. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1522. fi
  1523. enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
  1524. enabled bzlib && check_lib bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  1525. # check for some common methods of building with pthread support
  1526. # do this before the optional library checks as some of them require pthreads
  1527. if enabled pthreads; then
  1528. if check_func pthread_create; then
  1529. :
  1530. elif check_func pthread_create -pthread; then
  1531. add_cflags -pthread
  1532. add_extralibs -pthread
  1533. elif check_func pthread_create -pthreads; then
  1534. add_cflags -pthreads
  1535. add_extralibs -pthreads
  1536. elif check_func pthread_create -lpthreadGC2; then
  1537. add_extralibs -lpthreadGC2
  1538. elif ! check_lib pthread.h pthread_create -lpthread; then
  1539. die "ERROR: can't find pthreads library"
  1540. fi
  1541. fi
  1542. for thread in $THREADS_LIST; do
  1543. if enabled $thread; then
  1544. test -n "$thread_type" &&
  1545. die "ERROR: Only one thread type must be selected." ||
  1546. thread_type="$thread"
  1547. fi
  1548. done
  1549. check_lib math.h sin -lm
  1550. # test for C99 functions in math.h
  1551. for func in llrint lrint lrintf round roundf; do
  1552. check_exec <<EOF && enable $func || disable $func
  1553. #include <math.h>
  1554. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1555. EOF
  1556. done
  1557. # these are off by default, so fail if requested and not available
  1558. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1559. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1560. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1561. enabled libdirac && add_cflags "$(pkg-config --cflags dirac)" &&
  1562. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
  1563. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
  1564. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1565. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1566. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1567. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1568. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1569. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  1570. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  1571. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1572. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1573. enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm &&
  1574. { check_cpp_condition x264.h "X264_BUILD >= 65" ||
  1575. die "ERROR: libx264 version must be >= 0.65."; }
  1576. enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
  1577. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1578. # libdc1394 check
  1579. if enabled libdc1394; then
  1580. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1581. enable libdc1394_2; } ||
  1582. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1583. enable libdc1394_1; } ||
  1584. die "ERROR: No version of libdc1394 found "
  1585. fi
  1586. _restrict=
  1587. for restrict_keyword in restrict __restrict__ __restrict; do
  1588. check_cc <<EOF && _restrict=$restrict_keyword && break
  1589. void foo(char * $restrict_keyword p);
  1590. EOF
  1591. done
  1592. test "$vhook" = "default" && vhook="$dlopen"
  1593. if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
  1594. disable vhook
  1595. echo
  1596. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1597. echo "Patches welcome."
  1598. echo
  1599. fi
  1600. if enabled vhook; then
  1601. check_ldflags -rdynamic
  1602. check_ldflags -export-dynamic
  1603. fi
  1604. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1605. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1606. ##########################################
  1607. # SDL check
  1608. disable sdl_too_old
  1609. disable sdl
  1610. SDL_CONFIG="${cross_prefix}sdl-config"
  1611. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  1612. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1613. temp_cflags $sdl_cflags
  1614. temp_extralibs `"${SDL_CONFIG}" --libs`
  1615. if check_lib2 SDL.h SDL_Init; then
  1616. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1617. if test "$_sdlversion" -lt 121 ; then
  1618. enable sdl_too_old
  1619. else
  1620. enable sdl
  1621. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1622. #include <SDL.h>
  1623. int main(int argc, char **argv){
  1624. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1625. int w = vi->current_w;
  1626. return 0;
  1627. }
  1628. EOF
  1629. fi
  1630. fi
  1631. restore_flags
  1632. fi
  1633. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  1634. ##########################################
  1635. # Network check
  1636. if enabled network; then
  1637. check_type sys/socket.h socklen_t
  1638. # Prefer arpa/inet.h over winsock2
  1639. if check_header arpa/inet.h ; then
  1640. check_func closesocket
  1641. elif check_header winsock2.h ; then
  1642. network_extralibs="-lws2_32"
  1643. check_type ws2tcpip.h socklen_t
  1644. check_func_headers winsock2.h closesocket
  1645. fi
  1646. fi
  1647. ##########################################
  1648. # IPv6 check
  1649. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1650. #include <sys/types.h>
  1651. #include <sys/socket.h>
  1652. #include <netinet/in.h>
  1653. #include <netdb.h>
  1654. int main(void) {
  1655. struct sockaddr_storage saddr;
  1656. struct ipv6_mreq mreq6;
  1657. getaddrinfo(0,0,0,0);
  1658. getnameinfo(0,0,0,0,0,0,0);
  1659. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1660. }
  1661. EOF
  1662. check_header linux/videodev.h
  1663. check_header linux/videodev2.h
  1664. check_header sys/videoio.h
  1665. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1666. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1667. { check_header dev/bktr/ioctl_meteor.h &&
  1668. check_header dev/bktr/ioctl_bt848.h; } ||
  1669. { check_header machine/ioctl_meteor.h &&
  1670. check_header machine/ioctl_bt848.h; } ||
  1671. { check_header dev/video/meteor/ioctl_meteor.h &&
  1672. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1673. check_header dev/ic/bt8xx.h
  1674. check_header sys/soundcard.h
  1675. check_header soundcard.h
  1676. # deal with the X11 frame grabber
  1677. enabled x11grab &&
  1678. check_header X11/Xlib.h &&
  1679. check_header X11/extensions/XShm.h &&
  1680. check_func XOpenDisplay -lX11 &&
  1681. check_func XShmCreateImage -lX11 -lXext
  1682. enabled debug && add_cflags -g"$debuglevel"
  1683. # add some useful compiler flags if supported
  1684. check_cflags -Wdeclaration-after-statement
  1685. check_cflags -Wall
  1686. check_cflags -Wno-switch
  1687. check_cflags -Wdisabled-optimization
  1688. check_cflags -Wpointer-arith
  1689. check_cflags -Wredundant-decls
  1690. check_cflags -Wno-pointer-sign
  1691. check_cflags -Wcast-qual
  1692. check_cflags -Wwrite-strings
  1693. check_cflags -Wtype-limits
  1694. enabled extra_warnings && check_cflags -Winline
  1695. # add some linker flags
  1696. check_ldflags -Wl,--warn-common
  1697. check_ldflags -Wl,--as-needed
  1698. 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'
  1699. check_ldflags -Wl,-Bsymbolic
  1700. if enabled small; then
  1701. check_cflags -Os # not all compilers support -Os
  1702. optimizations="small"
  1703. elif enabled optimizations; then
  1704. if $cc -v 2>&1 | grep -q xlc; then
  1705. add_cflags "-O5"
  1706. add_ldflags "-O5"
  1707. else
  1708. add_cflags "-O3"
  1709. fi
  1710. fi
  1711. check_cflags -fno-math-errno
  1712. check_cflags -fno-signed-zeros
  1713. # add some flags for Intel C Compiler
  1714. if $cc --version 2> /dev/null | grep -q Intel; then
  1715. # Just warnings, no remarks
  1716. check_cflags -w1
  1717. # -wd: Disable following warnings
  1718. # 144, 167, 556: -Wno-pointer-sign
  1719. # 10006: ignoring unknown option -fno-signed-zeros
  1720. # 10156: ignoring option '-W'; no argument required
  1721. check_cflags -wd144,167,556,10006,10156
  1722. # 11030: Warning unknown option --as-needed
  1723. # 10156: ignoring option '-export'; no argument required
  1724. check_ldflags -wd10156,11030
  1725. # Allow to compile with optimizations
  1726. check_ldflags -march=$cpu
  1727. fi
  1728. # PIC flags for shared library objects where they are needed
  1729. if enabled shared; then
  1730. # LIBOBJFLAGS may have already been set in the OS configuration
  1731. if test -z "$LIBOBJFLAGS" ; then
  1732. case "$arch" in
  1733. x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
  1734. esac
  1735. fi
  1736. fi
  1737. if enabled gprof; then
  1738. add_cflags "-p"
  1739. add_ldflags "-p"
  1740. fi
  1741. VHOOKCFLAGS="-fPIC"
  1742. # Find out if the .align argument is a power of two or not.
  1743. if test $asmalign_pot = "unknown"; then
  1744. disable asmalign_pot
  1745. echo '__asm__ (".align 3");' | check_cc && enable asmalign_pot
  1746. fi
  1747. enabled_any $DECODER_LIST && enable decoders
  1748. enabled_any $ENCODER_LIST && enable encoders
  1749. enabled_any $BSF_LIST && enable bsfs
  1750. enabled_any $DEMUXER_LIST && enable demuxers
  1751. enabled_any $MUXER_LIST && enable muxers
  1752. enabled_any $FILTER_LIST && enable filters
  1753. enabled_any $INDEV_LIST && enable demuxers
  1754. enabled_any $OUTDEV_LIST && enable muxers
  1755. enabled_any $PROTOCOL_LIST && enable protocols
  1756. enabled_any $THREADS_LIST && enable threads
  1757. check_deps $CONFIG_LIST \
  1758. $HAVE_LIST \
  1759. $DECODER_LIST \
  1760. $ENCODER_LIST \
  1761. $PARSER_LIST \
  1762. $BSF_LIST \
  1763. $DEMUXER_LIST \
  1764. $MUXER_LIST \
  1765. $FILTER_LIST \
  1766. $INDEV_LIST \
  1767. $OUTDEV_LIST \
  1768. $PROTOCOL_LIST \
  1769. enabled libdc1394 && append pkg_requires "libraw1394"
  1770. enabled libdirac && append pkg_requires "dirac"
  1771. enabled libtheora && append pkg_requires "theora"
  1772. enabled libvorbis && append pkg_requires "vorbisenc"
  1773. echo "install prefix $prefix"
  1774. echo "source path $source_path"
  1775. echo "C compiler $cc"
  1776. echo ".align is power-of-two $asmalign_pot"
  1777. echo "ARCH $arch ($cpu)"
  1778. if test "$build_suffix" != ""; then
  1779. echo "build suffix $build_suffix"
  1780. fi
  1781. if test "$extra_version" != ""; then
  1782. echo "version string suffix $extra_version"
  1783. fi
  1784. echo "big-endian ${bigendian-no}"
  1785. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1786. echo "yasm ${yasm-no}"
  1787. echo "MMX enabled ${mmx-no}"
  1788. echo "CMOV enabled ${cmov-no}"
  1789. echo "CMOV is fast ${fast_cmov-no}"
  1790. echo "EBX available ${ebx_available-no}"
  1791. echo "EBP available ${ebp_available-no}"
  1792. fi
  1793. if test $arch = "armv4l"; then
  1794. echo "ARMv5TE enabled ${armv5te-no}"
  1795. echo "ARMv6 enabled ${armv6-no}"
  1796. echo "ARM VFP enabled ${armvfp-no}"
  1797. echo "IWMMXT enabled ${iwmmxt-no}"
  1798. echo "NEON enabled ${neon-no}"
  1799. fi
  1800. if test $arch = "mips"; then
  1801. echo "MMI enabled ${mmi-no}"
  1802. fi
  1803. if test $arch = "powerpc"; then
  1804. echo "AltiVec enabled ${altivec-no}"
  1805. echo "dcbzl available ${dcbzl-no}"
  1806. fi
  1807. echo "gprof enabled ${gprof-no}"
  1808. echo "debug symbols ${debug-no}"
  1809. echo "strip symbols ${stripping-no}"
  1810. echo "optimizations ${optimizations-no}"
  1811. echo "static ${static-no}"
  1812. echo "shared ${shared-no}"
  1813. echo "postprocessing support ${postproc-no}"
  1814. echo "software scaler enabled ${swscale-no}"
  1815. echo "new filter support ${avfilter-no}"
  1816. echo "filters using lavformat ${avfilter_lavf-no}"
  1817. echo "video hooking ${vhook-no}"
  1818. if enabled vhook; then
  1819. echo "Imlib2 support ${imlib2-no}"
  1820. echo "FreeType support ${freetype2-no}"
  1821. fi
  1822. echo "network support ${network-no}"
  1823. if enabled network; then
  1824. echo "IPv6 support ${ipv6-no}"
  1825. fi
  1826. echo "threading support ${thread_type-no}"
  1827. echo "SDL support ${sdl-no}"
  1828. if enabled sdl_too_old; then
  1829. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1830. fi
  1831. echo "Sun medialib support ${mlib-no}"
  1832. echo "AVISynth enabled ${avisynth-no}"
  1833. echo "libamr-nb support ${libamr_nb-no}"
  1834. echo "libamr-wb support ${libamr_wb-no}"
  1835. echo "libdc1394 support ${libdc1394-no}"
  1836. echo "libdirac enabled ${libdirac-no}"
  1837. echo "libfaac enabled ${libfaac-no}"
  1838. echo "libfaad enabled ${libfaad-no}"
  1839. echo "libfaad dlopened ${libfaadbin-no}"
  1840. echo "libgsm enabled ${libgsm-no}"
  1841. echo "libmp3lame enabled ${libmp3lame-no}"
  1842. echo "libnut enabled ${libnut-no}"
  1843. echo "libschroedinger enabled ${libschroedinger-no}"
  1844. echo "libtheora enabled ${libtheora-no}"
  1845. echo "libvorbis enabled ${libvorbis-no}"
  1846. echo "libx264 enabled ${libx264-no}"
  1847. echo "libxvid enabled ${libxvid-no}"
  1848. echo "zlib enabled ${zlib-no}"
  1849. echo "bzlib enabled ${bzlib-no}"
  1850. echo
  1851. for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
  1852. echo "Enabled ${type}s:"
  1853. eval list=\$$(toupper $type)_LIST
  1854. for part in $list; do
  1855. enabled $part && echo ${part%_*}
  1856. done | sort | pr -3 -t
  1857. echo
  1858. done
  1859. license="LGPL"
  1860. if enabled nonfree; then
  1861. license="unredistributable"
  1862. elif enabled gpl; then
  1863. license="GPL"
  1864. fi
  1865. echo "License: $license"
  1866. echo "Creating config.mak and config.h..."
  1867. echo "# Automatically generated by configure - do not modify!" > config.mak
  1868. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1869. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  1870. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  1871. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1872. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  1873. echo "prefix=$prefix" >> config.mak
  1874. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  1875. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  1876. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  1877. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  1878. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  1879. echo "CC=$cc" >> config.mak
  1880. echo "YASM=$yasmexe" >> config.mak
  1881. echo "AR=$ar" >> config.mak
  1882. echo "RANLIB=$ranlib" >> config.mak
  1883. echo "LN_S=$ln_s" >> config.mak
  1884. enabled stripping &&
  1885. echo "STRIP=$strip" >> config.mak ||
  1886. echo "STRIP=echo ignoring strip" >> config.mak
  1887. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1888. echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
  1889. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1890. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1891. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1892. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  1893. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1894. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1895. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1896. echo "BUILD_STATIC=$static" >> config.mak
  1897. echo "BUILDSUF=$build_suffix" >> config.mak
  1898. echo "FULLNAME=$FULLNAME" >> config.mak
  1899. echo "LIBPREF=$LIBPREF" >> config.mak
  1900. echo "LIBSUF=$LIBSUF" >> config.mak
  1901. echo "LIBNAME=$LIBNAME" >> config.mak
  1902. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1903. echo "SLIBSUF=$SLIBSUF" >> config.mak
  1904. echo "EXESUF=$EXESUF" >> config.mak
  1905. echo "EXTRA_VERSION=$extra_version" >> config.mak
  1906. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  1907. if enabled bigendian; then
  1908. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1909. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1910. fi
  1911. if enabled sdl; then
  1912. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1913. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1914. fi
  1915. if enabled texi2html; then
  1916. echo "BUILD_DOC=yes" >> config.mak
  1917. fi
  1918. get_version(){
  1919. name=$1
  1920. file=$source_path/$2
  1921. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  1922. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  1923. lcname=$(tolower $name)
  1924. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  1925. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  1926. }
  1927. get_version LIBSWSCALE libswscale/swscale.h
  1928. get_version LIBPOSTPROC libpostproc/postprocess.h
  1929. get_version LIBAVCODEC libavcodec/avcodec.h
  1930. get_version LIBAVDEVICE libavdevice/avdevice.h
  1931. get_version LIBAVFORMAT libavformat/avformat.h
  1932. get_version LIBAVUTIL libavutil/avutil.h
  1933. get_version LIBAVFILTER libavfilter/avfilter.h
  1934. if enabled shared; then
  1935. echo "BUILD_SHARED=yes" >> config.mak
  1936. echo "PIC=-fPIC -DPIC" >> config.mak
  1937. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  1938. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1939. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1940. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1941. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  1942. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1943. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1944. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  1945. fi
  1946. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1947. echo "EXTRALIBS=$extralibs" >> config.mak
  1948. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  1949. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1950. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  1951. $DECODER_LIST \
  1952. $ENCODER_LIST \
  1953. $PARSER_LIST \
  1954. $BSF_LIST \
  1955. $DEMUXER_LIST \
  1956. $MUXER_LIST \
  1957. $FILTER_LIST \
  1958. $PROTOCOL_LIST \
  1959. $INDEV_LIST \
  1960. $OUTDEV_LIST \
  1961. echo "#define restrict $_restrict" >> $TMPH
  1962. if enabled small; then
  1963. echo "#define av_always_inline" >> $TMPH
  1964. fi
  1965. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1966. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1967. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1968. # Apparently it's not possible to portably echo a backslash.
  1969. enabled asmalign_pot &&
  1970. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  1971. printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
  1972. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  1973. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  1974. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  1975. cmp -s $TMPH config.h &&
  1976. echo "config.h is unchanged" ||
  1977. mv -f $TMPH config.h
  1978. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  1979. # build tree in object directory if source path is different from current one
  1980. if enabled source_path_used; then
  1981. DIRS="\
  1982. doc \
  1983. libavcodec \
  1984. libavcodec/alpha \
  1985. libavcodec/armv4l \
  1986. libavcodec/bfin \
  1987. libavcodec/i386 \
  1988. libavcodec/mlib \
  1989. libavcodec/ppc \
  1990. libavcodec/sh4 \
  1991. libavcodec/sparc \
  1992. libavdevice \
  1993. libavfilter \
  1994. libavformat \
  1995. libavutil \
  1996. libpostproc \
  1997. libswscale \
  1998. tests \
  1999. tools \
  2000. vhook \
  2001. "
  2002. FILES="\
  2003. Makefile \
  2004. common.mak \
  2005. subdir.mak \
  2006. doc/texi2pod.pl \
  2007. libavcodec/Makefile \
  2008. libavdevice/Makefile \
  2009. libavfilter/Makefile \
  2010. libavformat/Makefile \
  2011. libavutil/Makefile \
  2012. libpostproc/Makefile \
  2013. libswscale/Makefile \
  2014. "
  2015. for dir in $DIRS ; do
  2016. mkdir -p $dir
  2017. done
  2018. for f in $FILES ; do
  2019. $ln_s "$source_path/$f" $f
  2020. done
  2021. fi
  2022. # build pkg-config files
  2023. pkgconfig_generate(){
  2024. name=$1
  2025. shortname=${name#lib}
  2026. comment=$2
  2027. version=$3
  2028. libs=$4
  2029. requires=$5
  2030. cat <<EOF > $name/$name.pc
  2031. prefix=$prefix
  2032. exec_prefix=\${prefix}
  2033. libdir=$libdir
  2034. includedir=$incdir
  2035. Name: $name
  2036. Description: $comment
  2037. Version: $version
  2038. Requires: $(disabled shared && echo $requires)
  2039. Requires.private: $(enabled shared && echo $requires)
  2040. Conflicts:
  2041. Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
  2042. Libs.private: $(enabled shared && echo $libs)
  2043. Cflags: -I\${includedir}
  2044. EOF
  2045. cat <<EOF > $name/$name-uninstalled.pc
  2046. prefix=
  2047. exec_prefix=
  2048. libdir=\${pcfiledir}
  2049. includedir=${source_path}
  2050. Name: $name
  2051. Description: $comment
  2052. Version: $version
  2053. Requires: $requires
  2054. Conflicts:
  2055. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2056. Cflags: -I\${includedir}
  2057. EOF
  2058. }
  2059. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2060. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2061. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2062. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
  2063. enabled avfilter &&
  2064. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  2065. enabled postproc &&
  2066. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2067. if enabled swscale; then
  2068. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  2069. else
  2070. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  2071. apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
  2072. fi