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.

2541 lines
74KB

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