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.

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