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.

2534 lines
73KB

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